C - C

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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

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.

题解:

题目大意:一个人下载歌,每q个时间单位能下载q-1个时间单位的歌,歌的长度为T,下到S的时候开始播放,如果歌还没下完且放到了还未下载的地方,则重头开始放,问一共要放多少次

题目分析:一开始从s开始,设下了cur秒后听和下的进度相同,则 s + (q - 1) / q * t = t,解得t = q * s,然后从头开始,设t'秒后进度相同,则(q - 1) / q * t' + cur = t',解得t' = t* q,可见直接拿第一次进度相同的时间乘q就是接下来每次进度相同的时间

#include <iostream>
using namespace std;
int main()
{
long long t,s,q,total=;
cin>>t>>s>>q;
if(t<=s) cout<<""<<endl;
else
{
while(t>s)
{
s=s*q;
total++;
}
}
cout<<total-<<endl; }

CodeForces 569A 第六周比赛C踢的更多相关文章

  1. CodeForces 478B 第六周比赛B题

    B - B Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Descriptio ...

  2. Codeforces 559A 第六周 O题

    Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...

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

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

  4. LightOJ 1317 第六周比赛A题

    A - A Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Description Y ...

  5. HUAS 2017暑假第六周比赛-题解

    A.Parenthesis 括号匹配的问题有一种经典的做法. 将左括号看成1,右括号看成-1,做一遍前缀和sum. 括号序列是合法的当且仅当\(sum[n]=Min(sum[1],sum[2].... ...

  6. 【FOL】第六周

    最近太忙,三周(第四.五.六周)一起记录一下. 1.完成了键盘的输入,顺便把之前鼠标输入改了一下(最早是在渲染循环里面处理鼠标事件) 2.UI控件方面,做了个Edit控件,把之前的Label.Imag ...

  7. 20145213《Java程序设计学习笔记》第六周学习总结

    20145213<Java程序设计学习笔记>第六周学习总结 说在前面的话 上篇博客中娄老师指出我因为数据结构基础薄弱,才导致对第九章内容浅尝遏止地认知.在这里我还要自我批评一下,其实我事后 ...

  8. 20145304 Java第六周学习报告

    20145304<Java程序设计>第六周学习总结 教材学习内容总结 1.InputStream与OutputStream: 在Java中,输入串流的代表对象为java.io.InputS ...

  9. 20145330第六周《Java学习笔记》

    20145330第六周<Java学习笔记> . 这周算是很忙碌的一周.因为第六周陆续很多实验都开始进行,开始要准备和预习的科目日渐增多,对Java分配的时间不知不觉就减少了,然而第十和十一 ...

随机推荐

  1. NOI题库1799 最短前缀

    1799:最短前缀 总时间限制: 1000ms 内存限制: 65536kB 描述 一个字符串的前缀是从该字符串的第一个字符起始的一个子串.例如 "carbon"的字串是: &quo ...

  2. Unicode 字符集及UTF-8 UTF-16编码

    很久以前发在他处的一篇博文,今天翻出来重新整理了一下 Unicode 字符集 共分为 17 个平面(plane), 分别对应 U+xx0000 - U+xxFFFF 的 code points, 其中 ...

  3. hdu 2795 线段树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 #include <cstdio> #include <cmath> # ...

  4. Lucene 4.10.2开发示例

    这里面用的是比较新的Lucene4.10.2 做的一个实例.(lucene的索引不能太大,要不然效率会很低.大于1G的时候就必须考虑分布索引的问题) 先介绍一下Lucene的几个参数意义: Index ...

  5. iOS开发之监测网络状态

    一.说明 在网络应用中,需要对用户设备的网络状态进行实时监控,有两个目的: (1)让用户了解自己的网络状态,防止一些误会(比如怪应用无能) (2)根据用户的网络状态进行智能处理,节省用户流量,提高用户 ...

  6. CF 19D Points 【线段树+平衡树】

    在平面上进行三种操作: 1.add x y:在平面上添加一个点(x,y) 2.remove x y:将平面上的点(x,y)删除 3.find x y:在平面上寻找一个点,使这个点的横坐标大于x,纵坐标 ...

  7. myeclipse html乱码

    myeclispe 中 html乱码 在页面的开头写上即可 <meta http-equiv="content-type" content="text/html;  ...

  8. 使用HTML5 WebDataBase设计离线数据库

    基于HTML5的Web DataBase 可以让你在浏览器中进行数据持久地存储管理和有效查询,假设你的离线应用程序有需要规范化的存储功能,那么使用Web DataBase,可以使你的应用程序无论是在离 ...

  9. Python爬虫:获取糗事百科笑话

    为了收集笑话也是挺拼的,我就不相信你所有的都看过了.还有,请问哪位仁兄能指点之下怎么把网上抓取到的图片写到word里面,捉摸了好久都没弄出来.   糗百不需要登录,html直接解析,只要在reques ...

  10. 鼠标双击范围基于Win7

    TP鼠标双击范围主要是修改Registry中的HKEY_CURRENT_USER\Control Panel\Mouse里面的两个参数 DoubleClickHeight跟DoubleClickWid ...