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 ≤ 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-1)/q(秒(歌曲)/秒)

当因为没有下载而歌曲停止播放时  从头开始听  问需要听几次歌 才能下载完成

题解:设x为停止播放的时间点

x=s+x*(q-1)/q

推出   x=s*q

当t<=x时说明歌曲已经下载完成

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<algorithm>
#define ll __int64
#define mod 1000000007
#define PI acos(-1.0)
using namespace std;
int t,s,q;
int main()
{
int have=;
scanf("%d %d %d",&t,&s,&q);
have=s+s*(q-);
int ans=;
while(t>have)
{
ans++;
have=have+have*(q-);
}
cout<<ans<<endl;
return ;
}

最新文章

  1. C# Azure 存储-分布式缓存Redis在session中的配置
  2. jquery 插件开发
  3. Spring-Context之二:使用Spring提供的测试框架进行测试
  4. 修改PHP网站默认首页
  5. 需要MARK一下,奇怪的ANDROID SDK自带的APK加密功能的问题
  6. 简易ORM(基于注解)
  7. iOS UITableViewCell AccessoryType属性
  8. Tomcat集群+Nginx+Redis服务搭建
  9. 01_Weblogic课程之概念篇:代理服务器,web服务器,应用程序服务器,JNDI概念,JTA概念,Java消息服务,Java验证和授权(JAAS),Java管理扩展,Web客户机,客户机应用程序
  10. CentOs下手动升级node版本
  11. InnoDB Insert Buffer(插入缓冲)
  12. laravel中请求用例$request可用的一些方法小结
  13. centos7下zabbix安装与部署
  14. Java实现Windows、Mouse监听器
  15. learning makefile VPATH
  16. 2. select下拉框获取选中的值
  17. POJ 1082
  18. IDA Pro基本简介
  19. ASP.NET四种页面导航方式之比较与选择
  20. js前台检测上传图片大小的总结

热门文章

  1. js实现全选,反选,全不选
  2. 问题003:JDK文件夹下的bin有什么作用?javac.exe和java.exe双击后为什么一闪而过,没了?
  3. SummerVocation_Learning--java的基本概念
  4. BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁(dp)
  5. python 实现剪刀石头布(三局两胜)
  6. 【PHP】foreach语法
  7. SourceTree 跳过登录注册,直接使用
  8. 第37课 thinkphp5添加商品基本信息及通过前置钩子上传商品主图 模型事件(勾子函数)
  9. Python 文件操作Error: binary mode doesn&#39;t take an encoding argument
  10. python实现导出excel表(前端+后端)