CodeForces 569A 第八次比赛 C题

Description

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.

Sample Input

Input

5 2 2

Output

2

Input

5 4 7

Output

1

Input

6 2 3

Output

1

Hint

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.

(解释是来至这位大牛的(一看就懂):http://blog.csdn.net/Tc_To_Top/article/details/47424809)

题目大意:一个人下载歌,每q个时间单位能下载q-1个时间单位的歌,歌的长度为T,下到S的时候开始播放,如果歌还没下完且放到了还未下载的地方,则重头开始放,问一共要放多少次

题目分析:一开始从s开始,设下了cur秒后听和下的进度相同,则 s + (q - 1) / q * cur = cur,解得cur = q * s,然后从头开始,设t‘秒后进度相同,则(q - 1) / q * t‘ + cur = t‘,解得t‘ = cur * q,可见直接拿第一次进度相同的时间乘q就是接下来每次进度相同的时间

代码如下:

 1 #include <stdio.h>
 2 int main()
 3 {
 4     double T,S,q,tin=0;
 5     int ans=1;
 6     scanf("%lf%lf%lf",&T,&S,&q);
 7     double xia=S*q;
 8     while(xia<T)
 9     {
10         xia*=q;
11         ans++;
12     }
13     printf("%d\n",ans);
14 }
时间: 2024-08-06 00:58:08

CodeForces 569A 第八次比赛 C题的相关文章

CodeForces 478B 第八次比赛 B题

Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a program th

CodeForces 569A 第六周比赛C踢

C - C Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 569A Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha lis

CodeForces 478B 第六周比赛B题

B - B Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair o

codeforces 459C - Pashmak and Buses 【构造题】

题目:codeforces 459C - Pashmak and Buses 题意:给出n个人,然后k辆车,d天时间,然后每天让n个人选择坐一辆车去上学,要去d天不能有任意两个人乘同一辆车,不能的话输出 -1 分类:数学,构造 分析:这个题目首先得分析,我开始想到的是首先用相同的放在一起,比如 7 2 3 这样构造 1 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 就是需要的天数跟每一行出现次数最多的数的出现次数相等,但是发现还有更优

【Codeforces 368A】Brain&#39;s Photos 水题

黑白灰都是#Black&White #include <cstdio> int n,m; int main() { scanf("%d%d",&n,&m); int ok=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++) { char s[5]; scanf("%s",s); if(s[0]!='W'&&s[0]!='B'&&s[0]!='G')

codeforces 707A A. Brain&#39;s Photos(水题)

题目链接: A. Brain's Photos 题意: 问是黑白还是彩色; 思路: 没有思路: AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> u

CSDN挑战编程——《金色十月线上编程比赛第一题:小女孩数数》

金色十月线上编程比赛第一题:小女孩数数 题目详情: [金色十月线上编程比赛规则] 一个小女孩正在用左手手指数数,从1数到n.她从拇指算作1开始数起,然后,食指为2,中指为3,无名指为4,小指为5.接下来调转方向,无名指算作6,中指为7,食指为8,大拇指为9,如此反复.问最后会停在那个手指上?用编号1.2.3.4.5依次表示大拇指.食指.中指.无名指.小指. 输入格式: 输入多组数据.每组数据占一行,只包含一个整数n(1<=n<=1000000000). 输出格式: 每组数据占一行,只包含一个介

CSDN挑战编程——《金色十月线上编程比赛第二题:解密》

金色十月线上编程比赛第二题:解密 题目详情: 小强是一名学生, 同时他也是一个黑客. 考试结束后不久,他惊讶的发现自己的高等数学科目居然挂了,于是他果断入侵了学校教务部网站.在入侵的过程中,他发现了与成绩相关的内容是一个加密文件,这个文件由 n 个数构成,经过分析,这个加密文件的密钥为这 n 个数中二进制位数 1 最少的数.但由于数比较多,小强 希望你能帮他得到密钥,好在成绩公布之前将成绩改过来. 输入描述: 输入由多组数据构成,每组数据第一行为一个数 n(1<=n<=10^5),表示数的数量

Codeforces 396B On Sum of Fractions 规律题

题目链接:点击打开链接 我们把 1 / { u(i)*v(i) }拆开->  (1/(u(i)-v(i)) * ( 1/v(i) - 1/u(i) ) 若n +1  是素数,则显然(1/(u(i)-v(i)) * ( 1/v(i) - 1/u(i) ) 这样完全相同的式子有 u(i)-v(i) 个 那么就可以把前面系数约掉,那么剩下的式子就是 1/2 - 1/(n+1) 若不是,则我们找到第一个<=n的素数,即v(n) 和第一个>n的素数,即 u(n) 然后前面的 2-v(n)求和,即