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
5 2 2
2
5 4 7
1
6 2 3
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就是接下来每次进度相同的时间
代码如下:
#include <stdio.h>
int main()
{
double T,S,q,tin=;
int ans=;
scanf("%lf%lf%lf",&T,&S,&q);
double xia=S*q;
while(xia<T)
{
xia*=q;
ans++;
}
printf("%d\n",ans);
}
CodeForces 569A 第八次比赛 C题的更多相关文章
- CodeForces 478B 第八次比赛 B题
Description n participants of the competition were split into m teams in some manner so that each te ...
- CodeForces 569A 第六周比赛C踢
C - C Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- LightOJ 1317 第八次比赛 A 题
Description You probably have played the game "Throwing Balls into the Basket". It is a si ...
- CodeForces 478B 第六周比赛B题
B - B Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descriptio ...
- codeforces 569A Music
codeforces 569A Music 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#pro ...
- CSDN挑战编程——《金色十月线上编程比赛第二题:解密》
金色十月线上编程比赛第二题:解密 题目详情: 小强是一名学生, 同一时候他也是一个黑客. 考试结束后不久.他吃惊的发现自己的高等数学科目竟然挂了,于是他果断入侵了学校教务部站点. 在入侵的过程中.他发 ...
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- codeforces 569A A. Music(水题)
题目链接: A. Music time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
随机推荐
- 如何在 Git 里撤销(几乎)任何操作
任何版本控制系统的一个最有的用特性就是“撤销 (undo)”你的错误操作的能力.在 Git 里,“撤销” 蕴含了不少略有差别的功能. 当你进行一次新的提交的时候,Git 会保存你代码库在那个特定时间点 ...
- OSChina中远程GIT仓库同步探索
GIT平台在OSChina中的搭建帮了我们很大的忙,但如何将本地GIT仓库上传至OSChina的远程仓库,相信这是一个艰难的坎,今天我就在此总结我的成功经验,帮助大家,共同学习.由于条件有限,我全部的 ...
- UGUI不规则按钮实现思路
根据图片的透明度来判断是否点击到了适当区域(如果a值是0,说明完全透明,则判断为没点击,否则判断为触发点击) using UnityEngine; using System.Collections; ...
- 【Unity Shaders】学习笔记——SurfaceShader(二)两个结构体和CG类型
[Unity Shaders]学习笔记——SurfaceShader(二)两个结构体和CG类型 转载请注明出处:http://www.cnblogs.com/-867259206/p/5596698. ...
- 长期内部推荐SAP职位,包括Java ABAP 咨询顾问,Developer,架构师等。
长期内部推荐SAP职位,包括Java ABAP 咨询顾问,Developer,架构师等. 有需要请发简历到邮箱 LoB Position LocationAcquisitions Hybris ...
- 学习总结 for循环语句的应用
for(初始值:条件表达式:状态改变) { } \n 表示换行 \ttab键 \\写出一个斜杠 例题解释 // 输出一个数,打印一到n出来 int n = int.Parse(Console. ...
- 使用Cookie保存商品浏览记录
数据流程:页面上是商品列表,点击<a href="productServlet">商品名</a> ==>跳转到自定义的servlet中进行处理,先得到 ...
- uitextview 最后一行遮挡
这只 uiscrollerview 的 setContentOffset CGRect line = [textView caretRectForPosition: textView.selected ...
- 部署Ossim
650) this.width=650;" title="29-1.jpg" alt="095310750.jpg" src="http:/ ...
- jQ复制按钮的插件zclip
zclip官网:http://www.steamdev.com/zclip/ swf文件国内下载:ZeroClipboard.swf jQuery-zclip是一个复制内容到剪贴板的jQuery插件, ...