国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

CodeforcesRound#190(Div.2)-A.CielandDancing_html/css

來源:懂視網 責編:小采 時間:2020-11-27 15:57:35
文檔

CodeforcesRound#190(Div.2)-A.CielandDancing_html/css

CodeforcesRound#190(Div.2)-A.CielandDancing_html/css_WEB-ITnose:Ciel and Dancing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they n
推薦度:
導讀CodeforcesRound#190(Div.2)-A.CielandDancing_html/css_WEB-ITnose:Ciel and Dancing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they n

Ciel and Dancing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:

  • either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);
  • or the girl in the dancing pair must dance for the first time.
  • Help Fox Ciel to make a schedule that they can dance as many songs as possible.

    Input

    The first line contains two integers n and m (1?≤?n,?m?≤?100) ? the number of boys and girls in the dancing room.

    Output

    In the first line print k ? the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.

    Sample test(s)

    input

    2 1

    output

    21 12 1

    input

    2 2

    output

    31 11 22 2

    Note

    In test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).

    And in test case 2, we have 2 boys with 2 girls, the answer is 3.






    解題思路:n個boy,m個girl,若每對舞伴中至少有一個之前一次也沒都跳過,問能夠組成多少對舞伴,并輸出。

    貪心,再加上點數學。稍微動點數學常識就可以得出,最多可以組成 n+m-1 對滿足要求的舞伴,然后就是怎么構造這么多對舞伴了。可以這樣想,我們先用1號boy跟所有的

    girl配對,然后再用剩下的n-1個boy分別跟最后一個girl配對即可。






    AC代碼:

    #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7fffffffint main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif int n,m; while(scanf("%d%d",&n, &m)!=EOF) { printf("%d\n", m + n - 1); for(int i=1; i<=m; i++) printf("%d %d\n", 1, i); for(int j=2; j<=n; j++) printf("%d %d\n", j, m); } return 0;}

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    CodeforcesRound#190(Div.2)-A.CielandDancing_html/css

    CodeforcesRound#190(Div.2)-A.CielandDancing_html/css_WEB-ITnose:Ciel and Dancing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they n
    推薦度:
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 精品欧美日韩一区二区三区 | 成人欧美一区二区三区在线 | 国产 日韩 欧美 综合 | 91精品专区| 亚洲一区 中文字幕 | 欧美在线一 | 国产精品久久久久久久久免费 | 伊人久久国产 | 日韩国产一区二区 | 成人看免费一级毛片 | 欧美日韩精品一区二区三区 | 国产原创一区二区 | 欧美精品亚洲精品日韩专区va | 亚洲欧美精品伊人久久 | 欧美视频日韩视频 | 一区在线免费观看 | 中文字幕日本一本二本三区 | 国产精品欧美激情在线播放 | 亚洲精品在线免费观看视频 | 一区二区三区在线观看免费 | 日韩欧美一区二区三区免费观看 | 久久精品国产一区 | 国产成人亚洲精品影院 | 九九九国产在线 | 天堂va欧美ⅴa亚洲va一国产 | 久久成人国产 | 尤物视频在线 | 国模私拍一区二区 | 午夜视频网| 在线观看国产欧美 | 亚洲国产精品热久久2022 | 国内精品久久久久久中文字幕 | 一区二区三区四区电影 | 伊人一级 | 欧美va免费精品高清在线 | 又黄又爽视频在线观看 | 91免费高清无砖码区 | 国产一级精品视频 | 中文字幕第一区 | 国产精品第 | 丝袜影音先锋 |