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

最新文章專(zhuān)題視頻專(zhuān)題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專(zhuān)題1關(guān)鍵字專(zhuān)題50關(guān)鍵字專(zhuān)題500關(guān)鍵字專(zhuān)題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關(guān)鍵字專(zhuān)題關(guān)鍵字專(zhuān)題tag2tag3文章專(zhuān)題文章專(zhuān)題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專(zhuān)題3
問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

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

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間: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
推薦度:
導(dǎo)讀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個(gè)boy,m個(gè)girl,若每對(duì)舞伴中至少有一個(gè)之前一次也沒(méi)都跳過(guò),問(wèn)能夠組成多少對(duì)舞伴,并輸出。

    貪心,再加上點(diǎn)數(shù)學(xué)。稍微動(dòng)點(diǎn)數(shù)學(xué)常識(shí)就可以得出,最多可以組成 n+m-1 對(duì)滿足要求的舞伴,然后就是怎么構(gòu)造這么多對(duì)舞伴了。可以這樣想,我們先用1號(hào)boy跟所有的

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






    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;}

    聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。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
    推薦度:
    標(biāo)簽: and div.2 codeforcesround#
    • 熱門(mén)焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門(mén)推薦

    專(zhuān)題
    Top
    主站蜘蛛池模板: 偷牌自拍 | 亚洲欧美视频一区二区三区 | 91香蕉国产亚洲一区二区三区 | 国产成人高清亚洲一区久久 | 国产成人精品一区二三区在线观看 | 亚洲国产福利 | 日本色图在线 | 欧美在线国产 | 欧美h网 | 九九久久亚洲综合久久久 | 国产成人成人一区二区 | 国产精品国产精品国产专区不卡 | 久久精品国产99久久99久久久 | xxxxx欧美| 亚洲免费一区 | 国产不卡网 | 亚洲福利视频 | 精品视频一区二区三区四区 | 任你躁欧美一级在线精品免费 | 香蕉乱码成人久久天堂爱免费 | 成人久久久观看免费毛片 | 欧美视频亚洲视频 | 国产麻豆91 | 国产精品九九久久精品女同 | 日韩精品免费观看 | 亚洲视频在线观看视频 | 亚洲视频免费一区 | 黄色在线观看网站 | 欧美精品色精品一区二区三区 | 国语视频 | 国产九区 | 青草青草伊人精品视频 | 国产毛片一区二区三区精品 | 亚洲国产成人久久一区二区三区 | 韩国美女vip福利一区 | 日韩小视频在线观看 | 久久er99 | 久久国产精品成人免费古装 | 国产一区二区三区免费在线观看 | 99热这里只有精品一区二 | 欧美一级在线观看 |