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 ...
随机推荐
- Win10重置 系统诸多设置或者菜单点击无效或者异常信息回复办法
cmd: 输入下列脚本重新注册DLL文件,待执行完毕后重启电脑 for %1 in (%windir%\system32\*.dll) do regsvr32.exe /s %1
- 上传预览图片的插件jquery-fileupload
上传预览图片的插件jquery-fileupload github地址:https://github.com/blueimp/jQuery-File-Upload 中文文档:http://www.jq ...
- HDFS 处理命令记录
hdfs dfs -ls hdfs dfs -mkdir hdfs dfs -put hdfs dfs -get hdfs dfs -cat hadoop 执行jar 输出的目录 必须要不存在的 y ...
- HDU_1269_tarjan求强连通分量
迷宫城堡 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- vue中怎样实现 路由拦截器
vue中怎样实现 路由拦截器(当用户没有登录的时候,跳转到登录页面,已经登录的时候,不能跳转到登录页,除非后台token失效) 在 我们需要实现这样 一个功能,登录拦截 其实就是 路由拦截,首先在定义 ...
- js-构造数组
js中,字符串的特性跟数组非常类似.数组是一种很重要的数据结构.在java中,数组声明的时候就要为其指定类型,数组中只能放同一种类型的数据.Js中的数组可以放不同的类型,但是是有序的,类似于java中 ...
- react功能实现-数组遍历渲染
在react中如何将一个数组遍历,并且逐个渲染在页面上? 1.在jsx渲染中,如果这个变量是一个数组,则会展开这个数组的所有成员. var arr = [ <h1>Hello world! ...
- Java8新特性 Stream流式思想(二)
如何获取Stream流刚开始写博客,有一些不到位的地方,还请各位论坛大佬见谅,谢谢! package cn.com.zq.demo01.Stream.test01.Stream; import org ...
- UVA133 - The Dole Queue【紫书例题4.3】
题意: n个人围成个圆,从1到n,一个人从1数到k就让第k个人离场,了另一个人从n开始数,数到m就让第m个人下去,直到剩下最后一个人,并依次输出离场人的序号. 水题,直接上标程了 #include&l ...
- Linux基础知识和命令
1,用户登录: root(管理员),权限最大.安全生产必要时再使用. 普通用户:权限有限.2, 终端终端设备终端:输入和输出设备,如:键盘鼠标显示器; 图形终端:虚拟机进入窗 ...