• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問(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#273(Div.2)BRandomTeams_html/css

    來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 15:56:32
    文檔

    CodeforcesRound#273(Div.2)BRandomTeams_html/css

    CodeforcesRound#273(Div.2)BRandomTeams_html/css_WEB-ITnose:題目鏈接:Random Teams B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n partici
    推薦度:
    導(dǎo)讀CodeforcesRound#273(Div.2)BRandomTeams_html/css_WEB-ITnose:題目鏈接:Random Teams B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n partici

    題目鏈接:Random Teams


    B. Random Teams

    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.

    Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.

    Input

    The only line of input contains two integers n and m, separated by a single space (1?≤?m?≤?n?≤?109) ? the number of participants and the number of teams respectively.

    Output

    The only line of the output should contain two integers kmin and kmax ? the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.

    Sample test(s)

    input

    5 1

    output

    10 10

    input

    3 2

    output

    1 1

    input

    6 3

    output

    3 6

    Note

    In the first sample all the participants get into one team, so there will be exactly ten pairs of friends.

    In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.

    In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.





    解題思路:n個(gè)人,m個(gè)隊(duì),只有在一個(gè)隊(duì)的人可以兩兩成為朋友,問(wèn)能比完賽后,朋友的對(duì)數(shù)的最大值和最小值為多少。

    很顯然,最大值的分法是有n-1個(gè)隊(duì)中只放一個(gè)人, 把剩下的人全放到剩下的那個(gè)隊(duì)。最少的分法是盡可能的均分n個(gè)人到m個(gè)隊(duì)。具體的朋友對(duì)數(shù)是簡(jiǎn)單的組合,k個(gè)人兩兩之間的朋友對(duì)數(shù)為 C(k,2) = k*(k-1)/2 .




    AC代碼:

    #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7ffffffflong long n, m, minn, maxn;long long c(long long x){ return (x*(x-1))/2;}int main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif while(scanf("%lld%lld",&n, &m)!=EOF) { long x = n/m; long y = n%m; if(m == 1) minn = c(n); else minn = y*c(x+1) + (m-y)*c(x); maxn = c(n-m+1); printf("%lld %lld\n", minn, maxn); } 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#273(Div.2)BRandomTeams_html/css

    CodeforcesRound#273(Div.2)BRandomTeams_html/css_WEB-ITnose:題目鏈接:Random Teams B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n partici
    推薦度:
    標(biāo)簽: div.2 codeforcesround# (div.2)
    • 熱門焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 一本大道无码日韩精品影视| 亚洲国产精品激情在线观看| 欧洲精品久久久av无码电影| 久久永久免费人妻精品下载| 日韩精品无码免费一区二区三区| 精品欧洲av无码一区二区三区| 777久久精品一区二区三区无码| 国产成人精品福利网站在线观看| 色久综合网精品一区二区| 欧美国产亚洲精品高清不卡| 色久综合网精品一区二区| 欧美日韩国产精品| 国产精品.XX视频.XXTV| 无夜精品久久久久久| 99久久国产热无码精品免费| 国产精品第一区第27页| 久久精品人人做人人爽97| 国产精品热久久毛片| 精品人妻中文字幕有码在线| 精品国产青草久久久久福利 | 国产精品伊人久久伊人电影| 亚洲国产精品无码专区在线观看| 国产精品第13页| 亚洲精品无码久久一线| 国产一区二区三区精品视频 | 精品日韩亚洲AV无码一区二区三区 | 高清在线亚洲精品国产二区| 亚洲精品乱码久久久久久中文字幕| 精品久久久久久久久久中文字幕| 国产91大片精品一区在线观看| 欧美亚洲色综久久精品国产| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 国产乱码精品一区二区三| 国产精品免费观看| 久久精品成人欧美大片| 亚洲精品你懂的| 亚洲国产精品综合久久网络| 亚洲精品A在线观看| 亚洲日韩精品无码一区二区三区| 午夜精品久久久久久99热| 国产精品综合色区在线观看|