ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

HDU - cable cable cable(数学)

2019-08-09 19:39:40  阅读:282  来源: 互联网

标签:HDU cable show color signal 数学 M2 M1 display


题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6195
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

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 \leq M \leq 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

4
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.

Problem solving report:

Description: 有m个显示器和k个信号源,每个显示器如果通过电缆连接一个信号源就会发某种光,要求是在m个显示器中任意选择k个都会显示k种不同的颜色,问最少需要多少电缆?
Problem solving: 假设我们已经连好k-1个,那么要想满足要求,则剩余的那些m-(k-1)个显示屏都要与最后那个信号源连接,所以每个信号源至少要连接m-(k-1)个显示屏,共有k个显示屏,所以共需要k*(m-(k-1))个光缆。

Accepted Code:

/* 
 * @Author: lzyws739307453 
 * @Language: C++ 
 */
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long m, k;
    while (~scanf("%lld%lld", &m, &k))
        printf("%lld\n", (m - (k - 1)) * k);
    return 0;
}

标签:HDU,cable,show,color,signal,数学,M2,M1,display
来源: https://blog.csdn.net/lzyws739307453/article/details/98979794

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有