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≤232−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
4 90Hint
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.
有k个发光源m个显示器每个显示器可以和一个光源之间连线连了之后就可以发出这个光源的颜色的光。问任意的选k个显示器这k个显示器发出k个不同的光最少需要多少根线把它们连起来。 这个题我想到的是鸽巢原理既然要选k个那么肯定有n-k个是没有的那么我们就把这n-k个给它连上鸽巢原理还得最小那肯定就是n-k+1再乘k个光源答案就是了 注意long long 和多组输入
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
const long long int inf=1e9+7;
int dp[200009][2];
int a[200009],b[200009];
int main(){
long long n,c;
while(cin>>n>>c){
long long ans=(n-c+1)*c;
cout<<ans<<endl;
}
}