HDU 6651 [2019 Multi-University Training Contest 7]

Final Exam

Problem Description

Final Exam is coming! Cuber QQ has now one night to prepare for tomorrow’s exam.

The exam will be a exam of problems sharing altogether m points. Cuber QQ doesn’t know about the exact distribution. Of course, different problems might have different points; in some extreme cases, some problems might worth 0 points, or all m points. Points must be integers; a problem cannot have 0.5 point.

What he knows, is that, these n problems will be about n totally different topics. For example, one could be testing your understanding of Dynamic Programming, another might be about history of China in 19th century. So he has to divide your night to prepare each of these topics separately. Also, if one problem is worth x points in tomorrow’s exam, it takes at least x+1 hours to prepare everything you need for examination. If he spends less than x+1 hours preparing, he shall fail at this problem.

Cuber QQ’s goal, strangely, is not to take as much points as possible, but to solve at least k problems no matter how the examination paper looks like, to get away from his parents’ scoldings. So he wonders how many hours at least he needs to achieve this goal.

Input

The first line of the input is an integer t (1≤t≤20 000), denoting the number of test cases.

Each test case are three space-separated integers n,m,k (0≤m≤109, 1≤k≤n≤109).

Output

For each test case, output the number of hours Cuber QQ needs.

Sample Input

2
1 10 1
10 109 10

Sample Output

11
1100

Hint

Cuber QQ should solve one problem in sample 1, so he at least prepares 11 hours when the problem one is 10 point.
Cuber QQ should solve all the ten problems in sample 2, so he at least prepares 110 hours for each problem because there may be one problem is 109 point.

思路

感觉这一次多校赛的题目都理解得很痛苦,这一道题大概是说把总分m分配给n道题目,QQ小方最少要过k道题,且复习每道题的时间是分值x+1,问我们最少需要多少分钟能够确保他一定能过k道题。在打多校赛的时候,我经过队友的讲解,大概明白了题目的意思,再看到一位大佬在水贴(狗头)给出的数据和相应答案,猜出了分值的分配方式,但其实并没有太看得懂题解的代码。
首先把k-1道题白给(全部设为0分),然后把m分尽可能平均分配给n-(k-1)道题,因为这样能够让你做出第k道题的时候所需时间最大。但是因为可能会出现无法完全分配的情况,所以求出cot1是分不完溢出的部分,然后求出没有溢出的部分cot2,但实际上不能分配那么多的cot2,这个我是经过多次实验得出的。
所以数据 10 109 4 的分值分配方式为 :
16 16 16 16 15 15 15 0 0 0
但是其复习时间分配应为 :
16 16 16 16 16 15 15 16 16 16
因为其顺序的不确定,所以需要即使是0分题也分配16分钟去复习,最坏情况是2个15抵消,4个16抵消,1个15和2个16解决3道0分题,1个16解决15分题。

代码

#include<iostream>
using namespace std;
typedef long long ll;

ll t,n,m,k,l,cot1,cot2;

int main() {
	cin >> t;
	while(t--) {
		cin >> n >> m >> k;
		k --;
		l = n - k;
		cot1 = m % l;
		cot2 = l - cot1 - 1;
		cot1 = n - cot2;
		cout << (m/l+1) * cot1 + (m/l) * cot2 << endl;
	}
}

/*
1
10 109 4
*/

题目来源

HDU 6651 Final Exam [2019 Multi-University Training Contest 7]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值