国产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精品国产一区二区 | 国产精品久久九九 | 久久91精品国产91久久户 | 国产精品一区二区久久精品 | 亚洲激情在线观看 | 亚洲欧美日韩三级 | 免费一级a毛片在线播 | 国产精品人成 | 日韩亚洲欧美在线 | 91精品成人免费国产 | 最新欧美日韩 | 国产呦系列 欧美呦 日韩呦 | 中文欧美日韩 | 国产第4页 | 欧美日韩精品一区二区在线播放 | 不卡一区二区在线观看 | 久久久久久亚洲精品中文字幕 | 日韩一区二区三区精品 | 色在线播放 | 欧美日韩综合精品一区二区三区 | 亚洲国产成人精品女人久久久 | 亚洲 欧美 中文 日韩专区 | 久久99九九精品免费 | 国产成人久久久精品毛片 | www.com黄色| 一级黄毛片| 国内久久 | 久久久久亚洲精品成人网小说 | 国产日韩欧美在线观看不卡 | 日韩系列第一页 | 无遮挡色视频 | 久久久久国产精品美女毛片 | 亚洲va国产日韩欧美精品 | 激情欧美一区二区三区中文字幕 | www.亚洲一区 | 精品偷自拍另类在线观看 | 五月精品 | 亚洲一区二区综合 | 亚洲另类第一页 | 亚洲小说欧美激情另类 | 欧美αv日韩αv另类综合 |