codeforces  569A   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

 

Input
5 2 2
Output
2
Input
5 4 7
Output
1
Input
6 2 3
Output
1

Sample Output

 

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-1)秒,每当播到未下载的部分时,返回从头开始播放。问下载这首歌需要从头开始播放多少次。

分析:

刚开始看这道题的时候完全不懂这是在干什么。

假设放到未下载点的时候用时x秒,每秒的下载速度(q-1)/q,x=s+x*(q-1)/q,则x=s*q。

代码:

 #include<cstdio>
#include<iostream>
using namespace std; int main()
{
int t,s,q;
int m=;
scanf("%d%d%d",&t,&s,&q);
while(s<t)//判断是否播完
{
s=s*q;
m++;
}
printf("%d\n",m);
return ;
}

codeforces 569A Music的更多相关文章

  1. CodeForces 569A 第六周比赛C踢

    C - C Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. codeforces 569A A. Music(水题)

    题目链接: A. Music time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  3. 【30.49%】【codeforces 569A】Music

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CodeForces 569A 第八次比赛 C题

    Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...

  5. Codeforces Round #315 (Div. 2A) 569A Music (模拟)

    题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. Python3 关于UnicodeDecodeError/UnicodeEncodeError: ‘gbk’ codec can’t decode/encode bytes类似的文本编码问题

    以下是小白的爬虫学习历程中遇到并解决的一些困难,希望写出来给后来人,如有疏漏恳请大牛指正,不胜感谢! 首先,我的代码是这样的 import requests url = 'http://www.acf ...

  2. Swagger+Spring MVC框架学习分享

    [html] view plain copy 最近参与公司接口编写,Android和IOS端都要调用这些接口,需要对接调试,如果没有一个接口文档,管理接口,别人用了接口,也不知道接口怎么用,接口上有什 ...

  3. Sencha Touch 2 结合HTML5的本地存储创建数据库实现增、删、改、查

    大家好!我是范范.本人刚接触ST2到现在刚刚两个月,6月1号接的项目,那时才知道有Sencha Touch2这个东西,到现在两个月了期间的幸酸就不说了.今天说说在项目中用到的HTML5的本地存储.可能 ...

  4. 高性能JSON库---FastJson(阿里巴巴)

    1.FastJSON简单介绍 Fastjson是一个Java语言编写的高性能功能完好的JSON库. 它採用一种"假定有序高速匹配"的算法,把JSON Parse的性能提升到极致,是 ...

  5. css3选择器的比较(二) -- 包含字符串

    二.  包含“字符串” 两种用法的区别是: a. “~=”,需要用空格分割, b. "*=",不需要任何分隔符 1. 资料 a) b)  2. html代码 <div tit ...

  6. Matlab常用小技巧及部分快捷键

    Matlab常用小技巧一: 1. m文件如果是函数,保存的文件名最好与函数名一致,这点都很清楚.不过容易疏忽的是,m文件名的命名尽量不要是简单的英文单词,最好是由大小写英文/数字/下划线等组成.原因是 ...

  7. Auto-Layout 的各种坑Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil'

    我们的很多人现在都在使用autolayout,用着也是非常爽但是有了这个东西以后更爽 很省事,什么都不用自己搞.Xcode完全搞定了,但是我终于为自己的懒惰付出了代价,再iphone4怎么运行怎么cr ...

  8. BZOJ 2096: [Poi2010]Pilots( set )

    用个set维护就可以水过去...O(NlogN) 应该可以用单调队列O(N).... --------------------------------------------------------- ...

  9. BZOJ 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富( dp )

    dp , dp[ i ][ j ] = max( dp[ k ][ j - 1 ] ) + G[ i ][ j ] ( i - 1 <= k <= i + 1 , dp[ k ][ j - ...

  10. 算法之旅,直奔<algorithm>之十五 find

    find(vs2010) 引言 这是我学习总结 <algorithm>的第十五篇.关于<algorithm>,每篇都很小,但是都很好用,可以秀出你的个性. 作用 find的作用 ...