A. Music(Codeforces Round #315 (Div. 2) 求最大的容纳量)
2 seconds
256 megabytes
standard input
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.
The single line contains three integers T, S, q (2 ≤ q ≤ 104, 1 ≤ S < T ≤ 105).
Print a single integer — the number of times the song will be restarted.
5 2 2
2
5 4 7
1
6 2 3
1
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) 求最大的容纳量)的更多相关文章
- Codeforces Round #315 (Div. 2) (ABCD题解)
比赛链接:http://codeforces.com/contest/569 A. Music time limit per test:2 seconds memory limit per test: ...
- 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 ...
- Codeforces Round #315 (Div. 2)
这次可以说是最糟糕的一次比赛了吧, 心没有静下来好好的去思考, 导致没有做好能做的题. Problem_A: 题意: 你要听一首时长为T秒的歌曲, 你点击播放时会立刻下载好S秒, 当你听到没有加载到的 ...
- 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是给定范围的,所以 ...
- 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( ...
- 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 ...
- Codeforces Round #315 (Div. 2B) 569B Inventory 贪心
题目:Click here 题意:给你n,然后n个数,n个数中可能重复,可能不是1到n中的数.然后你用最少的改变数,让这个序列包含1到n所有数,并输出最后的序列. 分析:贪心. #include &l ...
- Codeforces Round #315 (Div. 2A) 569A Music (模拟)
题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...
- 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 ...
随机推荐
- CALayer帧动画
CALayer帧动画 _sunLayer = [[CALayer alloc]init]; _sunLayer.contents = (id)[UIImage imageNamed:@"su ...
- MAC软连接
在mac上不设置环境变量有的时候也可以直接就访问到了某些文件.这个是为什么呢?答案是用了软连接. 1 查看加载文件 可以使用cat命令查看paths文件 cat etc/paths /usr/loca ...
- POJ 3230 DP
f[i][j]=max(f[i][j],f[i-1][k]-a[k][j]+b[i][j]) i->第i天 j-–>到第j个城市 #include <cstdio> #incl ...
- ios -使用NSLayoutConstraint实现多个view等宽等高等间距
@interface ViewController () { UIView *firstView; UIView *secondView; UIView *thirdView; } @end @imp ...
- MacOS 升级后pod 出现的问题
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad ...
- UID卡、CUID卡、FUID卡的区别
UID卡(国外称GEN1) 所有区块可被重复读写 卡片ID可改且使用后门指令更改ID ID可被重复修改 响应后门指令(意味着可被使用后门指令检测是否为克隆卡的机器发现) CUID卡(国外称GEN2) ...
- 通过Static 字段来维护状态是不是一个好主意
static是申明静态字段.静态方法或者静态类的修饰符.使用static申明的字段属于类型本身而不属于任何字段,声明的类也具有一些特别特性,比如不能实例化,不能继承等.用通俗化的语言来说,static ...
- windows10上安装mysql详细图文教程
在windows10上安装mysql详细图文教程 这篇文章主要介绍了在windows10上安装mysql详细图文教程,本文介绍的非常详细,具有参考借鉴价值,感兴趣的朋友一起看看吧 环境:windw ...
- 团体程序设计天梯赛-练习集-L1-030. 一帮一
L1-030. 一帮一 “一帮一学习小组”是中小学中常见的学习组织方式,老师把学习成绩靠前的学生跟学习成绩靠后的学生排在一组.本题就请你编写程序帮助老师自动完成这个分配工作,即在得到全班学生的排名后, ...
- matlab学习菜单控件的基本用法
编辑菜单项 上下文菜单,即弹出菜单 然后添加一个坐标系 添加回调函数 %余弦曲线x=0:0.01:2*pi;y=cos(x);axes(handles.axes1);%将坐标系的值写进h=plot(x ...