Music
Music
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#problem/C
题目:
Description
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.
Input
The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105).
Output
Print a single integer — the number of times the song will be restarted.
Sample Input
5 2 2
2
5 4 7
1
6 2 3
1
Hint
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秒可以下载(q-1)秒这首歌,第一次下载结束后,每次播放的同时会下载。求一共从头开始播放的次数。
分析:
一道很好的想法题,每当播放到之前的未download处时,由于播放的同时也在下载,所以总会再次下载了一些,理论上会无限循环播放和下载,但总会有个极限,可以记为S(当前可播放的时间)。
#include<iostream>
using namespace std;
int main()
{
int t,s,q,c=;
cin>>t>>s>>q;
while(s<t)
{
c++;
s=s*q;
}
cout<<c<<endl;
return ;
}
随机推荐
- 数据库字典 sql
SELECT 表名=case when a.colorder=1 then d.name else '' end, 表说明=case when a.colorder=1 then isnull(f.v ...
- 在Asp.Net MVC中PartialView与EditorFor和DisplayFor的区别
相同之处: PartialView, EditorFor 和 DisplayFor 都可以用作来实现页面的公共部分,其他页面可以根据需求来引用. 不同之处: PartialView 是从Page的角度 ...
- hihocoder #1333 : 平衡树·Splay2
描述 小Ho:好麻烦啊~~~~~ 小Hi:小Ho你在干嘛呢? 小Ho:我在干活啊!前几天老师让我帮忙管理一下团队的人员,但是感觉好难啊. 小Hi:说来听听? 小Ho:事情是这样的.我们有一个运动同好会 ...
- 使用canvas实现擦玻璃效果---转载
<!DOCTYPE html> <html> <head lang="zh"> <meta name="viewport&quo ...
- 【项目经验】——JSON.parse() && JSON.stringify()
我们在做项目的时候,都知道序列化和反序列化,师哥说:"有正就有反,有来就有回!"的确,就是这样.然后我们在这里分享一下JSON.stringify() 和JSON.parse() ...
- 用PHP链接mysql数据库
PHP提供了两套数据库可用于访问mysql数据库 1)MySQL扩展函数数据库 2)MySQLI扩展数据库(improved) 使用MySQLI函数访问MySQL数据库步骤 1)链接数据库管理系统 m ...
- 解决mysql shell执行中文表名报command not found错误
mysql -h 192.168.22.201 -uusername -ppassword --default-character-set=utf8 rom3 -e "DELETE FROM ...
- POJ 1182 食物链 (经典带权并查集)
第三次复习了,最经典的并查集 题意:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们 ...
- java 日历代码实现
System.out.println("请输入日期(按照格式:2030-3-10):"); //在控制台输入 //String str="2016-9-26"; ...
- js的一些小笔记,(不定期更新)
2个$的用法$本身并无特定意义,它表示什么意思要看是如何定义的,如果没有定义就便是两个$,可能是变量名的开始.一般是一个函数,用来代替document.getElementByIdfunction $ ...