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.

(解释是来至这位大牛的(一看就懂):http://blog.csdn.net/Tc_To_Top/article/details/47424809)

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

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

代码如下:

 #include <stdio.h>
int main()
{
double T,S,q,tin=;
int ans=;
scanf("%lf%lf%lf",&T,&S,&q);
double xia=S*q;
while(xia<T)
{
xia*=q;
ans++;
}
printf("%d\n",ans);
}

CodeForces 569A 第八次比赛 C题的更多相关文章

  1. CodeForces 478B 第八次比赛 B题

    Description n participants of the competition were split into m teams in some manner so that each te ...

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

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

  3. LightOJ 1317 第八次比赛 A 题

    Description You probably have played the game "Throwing Balls into the Basket". It is a si ...

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

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

  5. codeforces 569A Music

    codeforces  569A   Music   解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#pro ...

  6. CSDN挑战编程——《金色十月线上编程比赛第二题:解密》

    金色十月线上编程比赛第二题:解密 题目详情: 小强是一名学生, 同一时候他也是一个黑客. 考试结束后不久.他吃惊的发现自己的高等数学科目竟然挂了,于是他果断入侵了学校教务部站点. 在入侵的过程中.他发 ...

  7. Codeforces Round #609 (Div. 2)前五题题解

    Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...

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

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

  9. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

随机推荐

  1. C语言sizeof陷阱

    执行以下程序,查看输出: #include <stdio.h> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int  ...

  2. rsync拉取远程文件

    mkdir -p   /doc sshpass -p ''pwd" rsync -avz -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictH ...

  3. django中添加用户

    在django中添加用户,直接在auth_user表中添加会有问题,因为这里密码是加密的,可以通过manage.py shell加入 创建User: 1 >>> from djang ...

  4. 洛谷P1470 最长前缀 Longest Prefix

    P1470 最长前缀 Longest Prefix 73通过 236提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 求大神指导,为何错? 题目描述 在生 ...

  5. VC7 HTML Dialog开发实例讲解

    开发环境:VS7,Windows XP,Windows 2K 在VS7中添加了一种新的对话框类:CDHtmlDialog,顾名思义就是能够显示DHTML内容的对话框,但不同与以前的CHTMLView不 ...

  6. coffeeScript 语法总结

    CoffeeScript ---->安装node.js ---->安装coffeeScript 语句: 注意:没有分号,语句由新的一行结束:多条语句写到同一行时需要分号表示一条语句的结束( ...

  7. windows svn

    1.1Svn和VisualSvn介绍 VisualSvn Server2.5.6(版本控制服务器)免费开源软件 是基于Windows平台上的Subversion服务器,它是免费的 官方下载: http ...

  8. MSSQL Server Transaction 数据库事务回滚的用法

    使用的表结构如下:         Commit TransAction    Else        Rollback TransAction/*    自定义一个变量来判断最后是否发生过错误.*/ ...

  9. hadoop,hbase,pig安装

    注意端口,办公网只能访问8000-9000的端口 pig的一些lib文件版本 /home/map/hadoop/lib下一些98.5的lib没删除

  10. IOS CLLocationManager定位反编码位置信息

    //获取位置和坐标#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1        if (IOS_VERSION >= 8.0) {   ...