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.

Sample test(s)
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秒就会缓冲q-1秒的音乐,假设音乐播放到某一个地方可是还没有缓冲到。音乐就会又一次開始播放。如今问音乐播放完成时音乐又一次播放了几次

点击打开链接

#include <iostream>

using namespace std;

int t,s,q;

int main()
{
while(cin >> t >> s >> q)
{
int x = s;
int y=0;
int cnt=1;
while(x<t)
{
if(y+q<( x+q-1))
{
x = x+q-1;
y=y+q;
}
else if((y+q)==(x+q-1) )
{
if(y+q<t)
{
cnt++;
x=y+q;
y=0;
}
else
{
x=t;
}
}
else
{
x +=q-1;
cnt++;
y=0;
}
}
cout << cnt << endl;
}
return 0;
}

A. Music(Codeforces Round #315 (Div. 2) 求最大的容纳量)的更多相关文章

  1. Codeforces Round #315 (Div. 2) (ABCD题解)

    比赛链接:http://codeforces.com/contest/569 A. Music time limit per test:2 seconds memory limit per test: ...

  2. Codeforces Round #315 (Div. 1) A. Primes or Palindromes? 暴力

    A. Primes or Palindromes?Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3261 ...

  3. Codeforces Round #315 (Div. 2)

    这次可以说是最糟糕的一次比赛了吧, 心没有静下来好好的去思考, 导致没有做好能做的题. Problem_A: 题意: 你要听一首时长为T秒的歌曲, 你点击播放时会立刻下载好S秒, 当你听到没有加载到的 ...

  4. Codeforces Round #315 (Div. 2C) 568A Primes or Palindromes? 素数打表+暴力

    题目:Click here 题意:π(n)表示不大于n的素数个数,rub(n)表示不大于n的回文数个数,求最大n,满足π(n) ≤ A·rub(n).A=p/q; 分析:由于这个题A是给定范围的,所以 ...

  5. codeforces 568a//Primes or Palindromes?// Codeforces Round #315 (Div. 1)

    题意:求使pi(n)*q<=rub(n)*p成立的最大的n. 先收集所有的质数和回文数.质数好搜集.回文数奇回文就0-9的数字,然后在头尾添加一个数.在x前后加a,就是x*10+a+a*pow( ...

  6. Codeforces Round #315 (Div. 2) C. Primes or Palindromes? 暴力

    C. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input st ...

  7. Codeforces Round #315 (Div. 2B) 569B Inventory 贪心

    题目:Click here 题意:给你n,然后n个数,n个数中可能重复,可能不是1到n中的数.然后你用最少的改变数,让这个序列包含1到n所有数,并输出最后的序列. 分析:贪心. #include &l ...

  8. Codeforces Round #315 (Div. 2A) 569A Music (模拟)

    题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...

  9. 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 ...

随机推荐

  1. Spring 整合 Redis (零配置) 的简单使用

    pom.xml <!--jedis--> <dependency> <groupId>redis.clients</groupId> <artif ...

  2. shiro英语

    Security Manager安全管理人员 Tutorial 辅导的 transient 短暂的 Cipher 密码 Memory 记忆 Access 访问Handy Hint 方便提示separa ...

  3. CAGradientLayer 颜色渐变实现进度条

    #import <UIKit/UIKit.h> @interface TJGradientProgressView : UIView /** * 进度值 */ @property(nona ...

  4. 【原创】python中文编码问题深入分析(三):python2.7文件读写中文编码问题

    上一篇文章介绍和分析了python2.7中使用print遇到的中文编码问题的原因和解决方案,本篇主要介绍一下python2.7中执行文件读写可能遇到的编码问题. 1.文件读取 假如我们读取一个文件,文 ...

  5. 去除安卓apk中的广告

    一般来说,安卓应用很多免费的apk都是有广告的.尽管我们要坚持尊重开发者,帮帮他们点击广告赚钱来可持续发展,但是有的时候,很多游戏中游戏实在是太影响感觉了,当找不到汉化破解版本的时候,也许需要亲自把它 ...

  6. selenium获取页面通过样式隐藏获取不到元素解决方案

    如图更换图像这个按钮通过bottom:-30px隐藏了,通过如下代码获取不到页面元素,后台会报错 driver.findElement(By.className("js-avator-lin ...

  7. 浅析Python3中的bytes和str类型 (转)

    原文出处:https://www.cnblogs.com/chownjy/p/6625299.html#undefined Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分.文 ...

  8. gitlab变更邮箱后发送邮件报SSLError错误

    测试发送邮件: gitlab-rails console Notify.test_email('test666@example.com', 'Message Subject', 'Message Bo ...

  9. Pytorch基础(6)----参数初始化

    一.使用Numpy初始化:[直接对Tensor操作] 对Sequential模型的参数进行修改: import numpy as np import torch from torch import n ...

  10. [jzoj 5782]【NOIP提高A组模拟2018.8.8】 城市猎人 (并查集按秩合并+复杂度分析)

    传送门 Description 有n个城市,标号为1到n,修建道路花费m天,第i天时,若gcd(a,b)=m-i+1,则标号为a的城市和标号为b的城市会建好一条直接相连的道路,有多次询问,每次询问某两 ...