<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guā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)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題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:

      1. either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);
      2. or the girl in the dancing pair must dance for the first time.
      3. 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#
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲成a人片在线观看无码专区| **一级一级毛片免费观看| 日韩免费毛片视频| 亚洲一区二区三区免费在线观看 | 中文无码亚洲精品字幕| 久久久久久国产精品免费无码| 亚洲乱码国产乱码精品精| 国产亚洲精品免费视频播放| 奇米影视亚洲春色| 3344在线看片免费| 亚洲影院在线观看| 久久福利资源网站免费看| 国产成+人+综合+亚洲专| 成人免费777777| 青草久久精品亚洲综合专区| 日韩成人在线免费视频| 添bbb免费观看高清视频| 亚洲五月午夜免费在线视频| 中文字幕久无码免费久久| 亚洲国产成人久久综合碰碰动漫3d| 99久久免费精品高清特色大片| 亚洲人成日本在线观看| 日韩免费高清视频网站| www.xxxx.com日本免费| 亚洲av永久无码精品漫画| 亚洲免费黄色网址| 国产AV无码专区亚洲AV蜜芽| 久久久久亚洲精品无码网址| 91精品国产免费| 久久亚洲精品高潮综合色a片| 国产成人精品久久亚洲| 91久久精品国产免费一区| 亚洲精品中文字幕| 亚洲人成亚洲人成在线观看 | 久久国产免费观看精品| 亚洲人成网站在线观看播放动漫 | 色偷偷亚洲女人天堂观看欧| 可以免费观看的一级毛片| 无码国产精品一区二区免费模式| 亚洲香蕉久久一区二区| 亚洲人成无码网WWW|