Problem 1002 cable cable cable-2017 ACM/ICPC Asia Regional Shenyang Online

来源:互联网 发布:催收数据安全管理制度 编辑:程序博客网 时间:2024/04/30 06:09
原题:
  • Problem Description: 
    Connecting the display screen and signal sources which produce different color signals by cables, then the display screen can show the color of the signal source.Notice that every signal source can only send signals to one display screen each time. 
    Now you have M display screens and K different signal sources(K≤M≤2^32−1). Select K display screens from M display screens, how many cables are needed at least so that any K display screens you select can show exactly K different colors.

  • Input 
    Multiple cases (no more than 100), for each test case: 
    there is one line contains two integers M and K.

  • Output 
    Output the minimum number of cables N.

  • Sample Input 
    3 2 
    20 15

  • Sample Output 

    90

  • Hint 
    这里写图片描述 
    As the picture is shown, when you select M1 and M2, M1 show the color of K1, and M2 show the color of K2. 
    When you select M3 and M2, M2 show the color of K1 and M3 show the color of K2. 
    When you select M1 and M3, M1 show the color of K1.

#include <iostream>#include <iomanip>#include <algorithm>#include <cstdio>#include <cstring>#include <queue>#include <deque>#include <stack>#include <string>#include <cmath>#include <vector>#include <utility>#include <set>#include <map>#include <sstream>#include <climits>//#pragma comment(linker, "/STACK:1024000000,1024000000")#define pi acos(-1.0)#define INF 2147483647using namespace std;typedef long long LL;typedef pair<int,int > P;int main(){    LL M, K;    while (cin>>M>>K)    {        LL res=(M-K+1)*K;        cout<<res<<endl;    }    return 0;}


阅读全文
2 0
原创粉丝点击