题目链接:

A. Music

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ≤ 10^4, 1 ≤ S < T ≤ 10^5).

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.

题意:

下一首歌,每q秒下q-1秒的内容,问要听多少次歌的开头;每次听到歌下载的地方就跳到开头;

思路:

把式子列出来,设这次要下x秒的内容;(q-1)/q*(s+x)+s=s+x;最后化简得x=(q-1)*s;

AC代码:

/*2014300227    569A - 32    GNU C++11    Accepted    15 ms    4 KB*/
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+;
typedef long long ll;
const double PI=acos(-1.0);
int t,s,q;
int main()
{
scanf("%d%d%d",&t,&s,&q);
int ans=;
int x=(q-)*s;
while(s+x<t)
{
ans++;
s+=x;
x=s*(q-);
}
cout<<ans<<"\n"; return ;
}

最新文章

  1. Used Query
  2. Linux下apache+phppgadmin安装配置
  3. 分布式缓存之 memcache 实现分布式缓存
  4. 2. MongoDB基本操作 —— 用Mongo.exe操作数据库增删改查
  5. Python+Selenium进行UI自动化测试项目中,常用的小技巧2:读取配置文件(configparser,.ini文件)
  6. DialogFragment 自定义弹窗
  7. imeOptions 属性详解
  8. 《Code Complete》ch.22 开发者测试
  9. 一个人写的操作系统 - Sparrow OS
  10. 解决在Linux下安装Oracle时的中文乱码问题
  11. yum仓库
  12. windows端口占用处理工具
  13. ------ 解析因内核栈溢出导致的 “double fault” 蓝屏 ------
  14. 英文汉语切换的导航栏,纯css制作。
  15. LR回放https协议脚本失败: 错误 -27778: 在尝试与主机“www.baidu.com”connect 时发生 SSL 协议错误
  16. 【AHOI2005】病毒检测
  17. 018-继承-OC笔记
  18. day 09初始函数
  19. 被遗弃的depends2.2,替换解决方案——VS命令行
  20. E - Just a Hook HDU - 1698 线段树区间修改区间和模版题

热门文章

  1. .net 定时执行 windows 服务
  2. Leetcode Array 15 3sum
  3. 如何用openssl命令行生成证书
  4. adb 功能大全
  5. Npm 被公司墙解决方法
  6. Getting Started with the G1 Garbage Collector(译)
  7. Mysql 索引增加与删除
  8. 在另一个线程中无法用((CMainFrame *)AfxGetMainWnd())
  9. ubuntu 中文显示乱码问题 (转)
  10. Consumer Group Example