题目链接:

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

codeforces 569A A. Music(水题)的更多相关文章

  1. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  2. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  3. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  5. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  6. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

  7. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  8. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  9. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

随机推荐

  1. 利用DataSet部分功能实现网站登录

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. 获取input光标的x和y轴

    http://blog.csdn.net/kingwolfofsky/article/details/6586029 index.html <!DOCTYPE html> <html ...

  3. Apc缓存Opcode(转)

    1.PHP执行 PHP的运行阶段也分成三个阶段: Parse.语法分析阶段. Compile.编译产出opcode中间码. Execute.运行,动态运行进行输出.                   ...

  4. sphinx PDF 中文

    使用reST撰写文档时,需要分多个文档时,就必须使用sphinx了,sphinx说起来很简单的,但是默认是不是支持中文的.幸好我出生的晚,sphinx现在已经支持xelatex了^_^ 安装 除了pa ...

  5. 去掉activity默认动画效果的方法

    非常多手机都会自带一些Activity切换动画,项目中假设我们须要禁用掉系统Activity切换的动画.能够使用例如以下方法: 一.重写Activity的Them中的windowAnimationSt ...

  6. kvm&vnc 简单安装shell脚本

    #!/bin/bash # created on 2014/7/15 #author : derrick.jiang (Email: derrick.jiang.maichuang.net) echo ...

  7. zoj 2068 - Chopsticks

    题目:非常多人在一起吃饭.有两组单支的筷子,定义badness为一对筷子长度差的平方,求最小的badness和. 分析:dp,最大公共子序列类似物. 这里利用数学关系找到一个结论: a < b ...

  8. JS实现图片无缝滚动特效;附addEventListener()方法、offsetLeft和offsetWidth属性。

    一:html部分 <body> <input id="btn1" type="button" value="向左"> ...

  9. 【BZOJ3291】Alice与能源计划 二分图最大匹配

    [BZOJ3291]Alice与能源计划 Description 在梦境中,Alice来到了火星.不知为何,转眼间Alice被任命为火星能源部长,并立刻面临着一个严峻的考验. 为了方便,我们可以将火星 ...

  10. kibana 查询语法

    根据某个字段查询 精确匹配: agent:"Mozilla/5.0" 如果不带双引号,只要包含指定值就可以搜索到 agent:Mozilla/5.0 如果是数值类型没有以上区别 数 ...