【CodeForces - 195A】Let's Watch Football (追及问题,模拟)
題干:
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some?integer?number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is?c?seconds and Valeric and Valerko wait?tseconds before the watching. Then for any moment of time?t0,?t?≤?t0?≤?c?+?t, the following condition must fulfill: the size of data received in?t0?seconds is not less than the size of data needed to watch?t0?-?t?seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers?a,?b?and?c?(1?≤?a,?b,?c?≤?1000,?a?>?b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1Output
3Input
10 3 2Output
5Input
13 12 1Output
1Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4?·?1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2?·?10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
?
題目大意:
? ?輸入a,b,c,第一個數字(a)表示觀看一秒鐘視頻所需的數據大小。第二個數字(b)表示每秒可以從網絡下載的數據大小。第三個數字(c)表示視頻的長度(以秒為單位)。問我如果想中間不停頓的播放,則至少需要等他下載多少秒再開始播放?
解題報告:
? ? 菜啊,,想錯式子了啊剛開始。一直想推一個追及的式子,結果用時間的等式或者用下載量的等式,最后都推出來類似1=1的東西,,,崩潰,,后來發現不能這么看,因為提前幾秒下載的時間你是不知道的啊。其實設提前下載t秒,一共視頻是c秒,這個告訴你了,所以t*b+c*b=a*c就可以了。。。。并且需要向上取整。。。水題
AC代碼:
#include<bits/stdc++.h> using namespace std;int main() {int a,b,c;double x;cin>>a>>b>>c;x=a*c-b*c;printf("%d\n",(int)ceil(x/b));return 0 ; }?
總結
以上是生活随笔為你收集整理的【CodeForces - 195A】Let's Watch Football (追及问题,模拟)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新能源的行情还能持续多久?新能源的潜力有
- 下一篇: 抖音粉丝破7200万!刘畊宏说周杰伦留给