题干:

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.

Examples

Input

5 2 2

Output

2

Input

5 4 7

Output

1

Input

6 2 3

Output

1

Note

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的内容(即下载速度为q-1秒 / q秒)。

解题报告:

类似一个追及问题,设temp秒后听到没有下载的地方,即在第temp秒时,他俩相遇(“播放”和“下载”)得到temp*(q-1)/q + S = temp 即 temp = q*S,直到 S > T 表示下载完毕。

AC代码:

#include<bits/stdc++.h>using namespace std;int T,S,q;int main()
{while(~scanf("%d%d%d",&T,&S,&q)){int sum = 0;while(S < T){S = S * q;sum++;}printf("%d\n",sum);}return 0;
}

【CodeForces - 569A】Music (数学公式化简,模拟追及问题)相关推荐

  1. 小学计算机教师业务考试题库,小学数学教师业务模拟考试试题

    小学数学教师业务模拟考试试题 (14页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 14.9 积分 平安小学数学教师业务模拟考试试题(一)一.填空(每空0 ...

  2. 八年级上册计算机期末考试题,八年级上册数学期末考试模拟试题及答案

    <八年级上册数学期末考试模拟试题及答案>由会员分享,可在线阅读,更多相关<八年级上册数学期末考试模拟试题及答案(10页珍藏版)>请在人人文库网上搜索. 1.八年级上册数学期末考 ...

  3. 【51nod - 1098】 最小方差(基础数学,公式化简,前缀和,积的前缀和)

    题干: 若x1,x2,x3--xn的平均数为k. 则方差s^2 = 1/n * [(x1-k)^2+(x2-k)^2+--.+(xn-k)^2] . 方差即偏离平方的均值,称为标准差或均方差,方差描述 ...

  4. Codeforces Round #249 (Div. 2) (模拟)

    Codeforces Round #249 (Div. 2) (模拟) C. Cardiogram time limit per test 1 second memory limit per test ...

  5. 四年级用计算机算出本月合计,四年级数学下册简算练习题及答案

    四年级数学下册简算练习题及答案 导语:学问是异常珍贵的东西,从任何源泉吸收都不可耻.下面是小编为大家整理的,数学知识,更多相关信息请关CNFLA学习网! 一.知识万花筒. 1.特快列车1小时大约行16 ...

  6. (五)《数电》——化简法(公式化简法和卡诺图化简法)

    目录 公式化简法 指定器件的逻辑函数化简 最小项 定义 性质 ​编辑 最大项 定义 性质 两者之间的关系 "最小项之和"形式 "最大项之积"形式 卡诺图 定义 ...

  7. 2021年暑假数学建模第一次模拟赛:新冠疫情预测(插值,时间序列,微分方程建模)

    本系列赛题.数据获取: 2021年暑假数学建模模拟赛(赛题+数据+分析) 不直接提供论文等资料,分析已经很详细了 整理不易,欢迎点赞+关注+收藏 2021年暑假数学建模第一次模拟赛:新冠疫情预测(插值 ...

  8. 常用数学化简技巧与常用公式[运算能力辅导]

    前言 从网上得到启示,才着手整理总结了自己近几年高三一线教学体会,本博文主要涉及有关运算的方面的化简技巧和常用公式,整理的初衷就是看,能不能帮助提升学生的运算能力.实际更多的想法是抛砖引玉,让高三学生 ...

  9. 数字逻辑——反函数、对偶函数,用逻辑代数公式化简为最简与或式练习题

    一.问题描述 1.求下面函数的反函数和对偶函数: 2.试用逻辑代数公式化简下列各式为最简与或式: 二.问题解答

最新文章

  1. php截取数组中的字符串,PHP 中使用explode()函数切割字符串为数组的示例
  2. python可变参数和关键字参数位置_python 参数笔记 -- 位置参数 关键字参数 命名参数 形式参数 默认参数 可变参数 可选参数 位置顺序...
  3. 携程Docker实践
  4. vim 删除一行_Vim 日常命令
  5. 产业链消息称台积电积极寻求更多长期代工订单
  6. 看完这些美食海报,你是不是又有灵感了?
  7. cfree mysql_如何配置CFree才能开发MySql数据库应用 | 学步园
  8. [洛谷P3346][ZJOI2015]诸神眷顾的幻想乡
  9. 废话少说 分析java抽象类与接口的区别
  10. RSS导入功能已完成
  11. 拓端tecdat|R语言生存分析: 时变竞争风险模型分析淋巴瘤患者
  12. java 数据类型转换
  13. HTML5代码雨程序
  14. 让DeepLearning4j阅读小说并给出关联度最高的词
  15. 华为云买网站买另外服务器,华为云网站在买其他服务器
  16. cesium等高线_Cesium专栏-空间分析之地形等高线(附源码下载)
  17. 如何计算 R 中卡方统计量的 P 值
  18. 阿里云云原生数据湖体系全解读——元原生数据湖体系
  19. @Scheduled出现Unexpected error occurred in scheduled task
  20. 电商交易规律、RFM分类

热门文章

  1. 3结构介绍_豹驰(BOACH)声学材料吸隔声方法介绍—(下)材料隔声特性曲线
  2. 软件测试之黑盒测试-等价类划分法
  3. mysql重连服务器失败_java – MySQL连接器错误“服务器时区值中...
  4. python图灵测试_最前沿:基于GAN和RL的思想来训练对话生成,通过图灵测试可期!...
  5. git add remote_最全的git常用命令(建议收藏)
  6. EISCONN的故事
  7. linux+qt+定时精度,Qt QTimer测试定时精度
  8. python10的因数_十五道Python小案例,学会这些,Python基础已过关!
  9. python安装后cmd找不到_关于Python3.6环境中,virtualenv找不到命令的解决方法
  10. java fx 建立窗体,3花式窗体与JavaFX CSS