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
  1. 5 2 2
Output
  1. 2
Input
  1. 5 4 7
Output
  1. 1
Input
  1. 6 2 3
Output
  1. 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就是接下来每次进度相同的时间

代码如下:

  1. #include <stdio.h>
  2. int main()
  3. {
  4. double T,S,q,tin=;
  5. int ans=;
  6. scanf("%lf%lf%lf",&T,&S,&q);
  7. double xia=S*q;
  8. while(xia<T)
  9. {
  10. xia*=q;
  11. ans++;
  12. }
  13. printf("%d\n",ans);
  14. }

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. 使用git管理github上的项目

    使用git可以把我们的项目代码上传到github上面去,方便自己管理,如何使用git?觉得是每位程序猿所必需要有的谋生技能,所以在此记录一下自己学会使用的这个过程: 一.需要注册github账号,这样 ...

  2. Centos7 Openstack - (第一节)基本环境配置

    Centos7 install Openstack - (第一节)基本环境配置 我的blog地址:http://www.cnblogs.com/caoguo 根据openstack官方文档配置 官方文 ...

  3. 《锋利的jQuery》

    学jQuery,向大家推荐一本书: 我读的书少,看见这样的解释不能立即解决我的困惑真的很烦. 还是动手最实际. 接下来会分多个文章举例分析各个方法的使用与效果. 大家可以到http://api.jqu ...

  4. c# 获取excel所有工作表

    var filePath="f:\xx.xlsx" string connStr = "Provider=Microsoft.Ace.OleDb.12.0;" ...

  5. APP发布Xcode7

    一.准备工作 1>准备3.5寸.4寸.4.7寸.5.5寸的程序截图至少个1张,如果支持iPad,那么iPad截图也要有.这些截图尽量截取页面漂亮的,因为这些截图是要放在AppStore中展示的. ...

  6. .net Url重写

    详细说明及下载dll源码路径: http://msdn.microsoft.com/zh-cn/library/ms972974.aspx 顺带上本人写的一个小例子:http://files.cnbl ...

  7. 农村的“无为教育” (FW)

    农村的“无为教育” 发布时间:2009年11月5日 11时33分 “以孩子影响孩子”,准确地说,是以偏远乡村贫困家庭的进取孩子,影响城市有相当收入的“问题孩子”.有两点值得注意,一是农村孩子影响城市孩 ...

  8. 企业内网信息安全实践-记ChinaUnix技术交流

    企业内网信息安全实践 随着棱镜计划的曝光,越来越多的信息安全的事件暴露在公众面前.对于企业来说,遭受到黑客攻击和破坏是家常便饭,只是您没有觉察到.自从09年就开始研究Ossim0.9版本,历经进10个 ...

  9. dell ipmi sol

    http://blog.arnoudvermeer.nl/post/52375062605/howto-setup-ipmi-sol-on-a-dell-r-series-server http:// ...

  10. centreon 画图x轴乱码

    rrdtool默认不指定locale,使用本地locale.乱码我估记是中文字体,由于操作系统最小化安装,本地没有中文字体,导致乱码. 1 安装中文字体 yum -y install wqy-zenh ...