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 ...
随机推荐
- SmartWiki开发日志之环境配置和系统安装
SmartWiki是基于laravel5.2开发的在线文档管理系统. 最低需要PHP5.6+MySql5.7.同时PHP需要开启一下扩展: MCrypt GD PDO PDO_mysql mbstri ...
- 支撑5亿用户、1.5亿活跃用户的Twitter最新架构详解及相关实现
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 摘要:Twitter出道之初只是个奋斗在RoR上的小站点,而如今已拥有1.5亿的活跃 ...
- noip2009 潜伏者
P1071 潜伏者 827通过 2.2K提交 题目提供者洛谷OnlineJudge 标签字符串模拟2009NOIp提高组 难度普及/提高- 提交该题 讨论 题解 记录 题目描述 R 国和 S 国正 ...
- android反编译工具总结
序:总结反编译主要的目的在于学习.利用反编译进行相关的汉化或修改,都是不道德的! 大家都知道,将apk文件解压后有两部分文件需要处理,一种是xml文件,另一种一个dex文件(.dex),我们可以从.d ...
- aspxgridView,Repeater增加自动序号列
第一种方式,直接在Aspx页面GridView模板列中.这种的缺点是到第二页分页时又重新开始了. <asp:TemplateField HeaderText="序号" Ins ...
- dll延迟加载
用于隐式链接选项, 这样设置后在exe调用dll的函数才会加载dll,调用DLL_PROCESS_ATTACH.否则隐式链接直接会在exe启动时加载dll
- 无法完成安装:'unsupported configuration: hda-duplex not supported in this QEMU binary'
Linux 有问必答:如何修复"hda-duplex not supported in this QEMU binary" 编译自:http://ask.xmodulo.com/h ...
- linux ---用uniq实现文件的并集和交集
1. 取出两个文件的并集(重复的行只保留一份) 2. 取出两个文件的交集(只留下同时存在于两个文件中的文件) 3. 删除交集,留下其他的行 1. cat file1 file2 | sort | un ...
- Android SQLite数据储存方式
SQLiteOpenHelper 类 用SQLiteOpenHelper 类中的 getWritableDatabase()和getReadableDatabase()方法可以获得数据库的引用. 为了 ...
- IIS报错 未将对象引用设置到对象的实例。
在vs中运行正常的项目 ,发布到IIS总是提示 未将对象引用设置到对象的实例. 运行静态页面 html正常,只是打开.aspx页面的时候报错,在确保了数据库,配置,权限均正常的情况下. 错误原因:先安 ...