HDOJ 6651 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

  • 多校自闭,不想学习,写写博客打法时间

  • 论如何在一晚上复习1100小时(八月加急名单

  • 思路
    答案就是
    ( 1 + ⌊ m n − k + 1 ⌋ ) ∗ ( k − 1 ) + m + 1 (1+ \lfloor{\frac{m}{n-k+1}}\rfloor)*(k-1)+m+1 1+nk+1m(k1)+m+1
    解释下,我们把题目理解成老师已知你的复习时间,他要如何干掉你?
    假设你复习第i题的时间是 t t t,显然他干掉你这题的最佳方法是使这题的分值为t。我们假设对于 i > 1 i>1 i>1,我们复习的时间ti>=ti-1
    老师干掉你的最佳方法是从第一题开始的分数mi=ti,直到 ∑ m i = m \sum{m}_i=m mi=m
    要使我们至少还有k题没被干掉,由于是求复习时间最少,我们假设前n-k题被老师干掉,要使第n-k+1题不被干掉我们显然有 ∑ i = 1 n − k + 1 t i > m \sum_{i=1}^{n-k+1}t_i>m i=1nk+1ti>m
    为了最小的复习时间显然有
    ∑ i = 1 n − k + 1 t i = m + 1 \sum_{i=1}^{n-k+1}t_i=m+1 i=1nk+1ti=m+1
    而剩下的由于时间成非严格递增,我们最小的花费即tn-k+1
    显然,是使tn-k+1最小即可,而易知 t m i n = 1 + ⌊ m n − k + 1 ⌋ t_{min}=1+\lfloor{\frac{m}{n-k+1}}\rfloor tmin=1+nk+1m证明完毕

  • 至于某群内某人说是复习(k-1)个tmin,和1个(m+1)完全是扯淡,善意的提醒一下

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值