A. Music(Codeforces Round #315 (Div. 2) 求最大的容纳量)
来源:互联网 发布:剑侠情缘3网游mac 编辑:程序博客网 时间:2024/06/05 06:30
Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.
Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite impatient. The song's duration is T seconds. Lesha downloads the first S seconds of the song and plays it. When the playback reaches the point that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is continued from the same place), and it happens until the song is downloaded completely and Lesha listens to it to the end. For q seconds of real time the Internet allows you to download q - 1 seconds of the track.
Tell Lesha, for how many times he will start the song, including the very first start.
The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105).
Print a single integer — the number of times the song will be restarted.
5 2 2
2
5 4 7
1
6 2 3
1
In the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.
In the second test, the song is almost downloaded, and Lesha will start it only once.
In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.
题意:一首歌会播放T秒,在第一次播放之前先缓冲s秒,播放后每q秒就会缓冲q-1秒的音乐,如果音乐播放到某一个地方但是还没有缓冲到,音乐就会重新开始播放,现在问音乐播放完毕时音乐重新播放了几次
点击打开链接
#include <iostream>using namespace std;int t,s,q;int main(){ while(cin >> t >> s >> q) { int x = s; int y=0; int cnt=1; while(x<t) { if(y+q<( x+q-1)) { x = x+q-1; y=y+q; } else if((y+q)==(x+q-1) ) { if(y+q<t) { cnt++; x=y+q; y=0; } else { x=t; } } else { x +=q-1; cnt++; y=0; } } cout << cnt << endl; } return 0;}
- A. Music(Codeforces Round #315 (Div. 2) 求最大的容纳量)
- A. Music-Codeforces Round #315 (Div. 2)
- Codeforces Round #315 (Div. 2) A. Music
- Codeforces Round #315 (Div. 2) A. Music
- Codeforces Round #315 (Div. 2)A. Music
- Codeforces Round #315 (Div. 2)569A Music(模拟)
- Codeforces Round #315 (Div. 2) A. Music (模拟)
- Codeforces Round #315 (Div. 2)569A Music(模拟)
- A Amr and Music( Codeforces Round #287 (Div. 2))
- Codeforces Round #287 (Div. 2) A. Amr and Music
- Codeforces Round #315 (Div. 2)(A,B)
- Codeforces Round #315 (Div. 2) A
- Codeforces Round #315 (Div. 2) A. Exam
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool (判断组成最大矩形)
- Codeforces Round #315 div2 A--Music 水题可结合数学推导
- Codeforces Round #346 (Div. 2) -A. Round House(模拟)
- Codeforce round #315 A music
- Codeforces Round #358 (Div. 2) E 计算几何 旋转卡壳求最大三角形面积
- leetcode_Decode Ways
- 程序员爱情表白专用html5动画网页的代码
- B - {A} + {B}
- 对象数组的使用
- Oracle整形转字符串to_char()
- A. Music(Codeforces Round #315 (Div. 2) 求最大的容纳量)
- 【SpringMVC整合MyBatis】springmvc异常处理-全局异常处理器开发
- 第84讲:Scala中List和ListBuffer设计实现思考
- 安卓拖动条
- HDU 1143 Tri Tiling
- 黑马程序员——OC笔记之类和对象
- 递归查询(知道父ID查子信息or知道子ID找父信息)
- [Win32] 服务程序开发(1)基本概念和服务程序的框架
- 【解决】Android自定义Dialog无法横向填满