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 ;
}

Codeforces Round #315 (Div. 2) A 水且坑的更多相关文章

  1. Codeforces Round #315 (Div. 2) B 水题强行set

    B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  2. Codeforces Round #365 (Div. 2) A 水

    A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  4. Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  5. Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs

    A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路

    A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  7. Codeforces Round #337 (Div. 2) A水

    A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. Codeforces Round #316 (Div. 2) A 水

    A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. Codeforces Round #362 (Div. 2) A 水也挂

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

随机推荐

  1. vue中created、mounted等方法整理

  2. ASP.NET补充

    字典类的子集 using System.Collections.Generic; Dictionary<string, string> dicB = new Dictionary<s ...

  3. primeng 中 pickList组件的使用

    primeng 是为angular 开发的一个强大的组建库,有很多强大的功能,拿来即用.但要真正满足自己的业务需求,就是按自己的需求进行修改,比如默认的样式等等. 进入正题. pickList 组件的 ...

  4. Dart Socket 与Java Socket连接

    -------------------------------------------------------------  Dart    SocketClient----------------- ...

  5. AIDE

    安装 yum install aide 修改配置文件 vim /etc/aide.conf (指定对哪些文件进行检测) /test/chameleon R /bin/ps R+a /usr/bin/c ...

  6. python 写 组合两两组合

    紧挨着 组合  a b c d  ----> ab ,bc ,cd portList = ['a', 'b', 'c', 'd'] for i, p in enumerate(portList) ...

  7. opengl 学习的链接,以后需要可以再来查需要的

    记录一些好的opengl学习站点,以供日后查阅: modern opengl tutorial : 一个英国的opengl学习网站 上面网站的中文版 日后发现新的再更新

  8. DDOS与DOS的区别

    0x01 在说之前,先看一些例子吧 还有众所周知的中美黑客大战,新闻我就不说了 0x02 什么是DOS DoS是Denial of Service的简称,即拒绝服务,造成DoS的攻击行为被称为DoS攻 ...

  9. 17.VUE学习之- v-for指令的使用方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. Python基础:输入与输出(I/O)

    来做一个NLP任务 步骤为: 1.读取文件: 2.去除所有标点符号和换行符,并把所有大写变成小写: 3.合并相同的词,统计每个词出现的频率,并按照词频从大到小排序: 4.将结果按行输出到文件 out. ...