国产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
    主站蜘蛛池模板: 欧美福利一区二区三区 | 欧美伊人久久大香线蕉综合69 | 久草伦理 | 国产亚洲第一页 | 国产在线观看免费 | 欧美aⅴ在线 | 亚洲欧美日韩高清一区二区一 | 日本三级电影网址 | 日韩高清dvd| 精品亚洲性xxx久久久 | 欧美在线观看一区二区三区 | 一道本在线播放 | 国产成人精品一区二区 | 欧美视频网站在线观看 | 日本激情网址 | 亚洲精品不卡久久久久久 | aa级毛片 | 欧美在线免费观看 | 亚洲一区日韩二区欧美三区 | 国产午夜视频在线观看 | 美日韩中文字幕 | 亚洲电影中文字幕 | 色阁阁| 韩国精品一区二区 | 激情一区| 欧美日本综合 | 久久精品国内一区二区三区 | 91精品久久久久久久久久 | 图片专区亚洲欧美另类 | 韩国精品一区二区 | 精品日韩在线 | 欧美日韩精品在线 | 亚洲欧美一区二区三区九九九 | 亚洲激情另类 | 热久久国产欧美一区二区精品 | 国产特级全黄一级毛片不卡 | 国产精品亚洲精品日韩动图 | 国产欧美一区二区精品性色99 | 国产日韩三级 | 精品在线免费观看 | 欧美日韩视频一区二区三区 |