• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答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
    主站蜘蛛池模板: 国产精品久久久久久久久鸭| 99香蕉国产精品偷在线观看| 国产精品高清一区二区三区不卡| 亚洲国产精品一区二区第一页免| 精品久久久久久无码人妻热| 久久久久国产精品嫩草影院| 免费国产在线精品一区| 亚洲精品岛国片在线观看| 亚洲精品国产成人片| 99久久精品国产高清一区二区 | 精品久久久久久国产91| 国产精品爽爽va在线观看网站| 国产精品久久成人影院| 国产精品免费久久| 夜夜高潮夜夜爽国产伦精品| 精品亚洲A∨无码一区二区三区| 国内精品免费在线观看| 精品人妻一区二区三区毛片| 久久精品国产亚洲Aⅴ香蕉| 国产精品视频色视频| 麻豆国内精品久久久久久| 久久Av无码精品人妻系列| 成人午夜精品亚洲日韩 | 亚洲精品国产首次亮相| jizz国产精品| 久久ww精品w免费人成| 精品久久久久中文字| 国产精品视频永久免费播放| 精品国产一区二区三区久久蜜臀| 精品无码国产污污污免费网站| 黄床大片免费30分钟国产精品| 91精品美女在线| 中文字幕亚洲精品无码| 国产精品成人啪精品视频免费| 国产精品国产三级国产AV主播| 日本精品一区二区久久久 | 精品亚洲永久免费精品| 日韩精品无码久久久久久 | 亚洲国产精品嫩草影院| 国产亚洲精品自在久久| 亚洲精品线路一在线观看|