CodeForce 569A
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.
程序分析:题意给出,下载一首歌,刚开始下载s,然后,当听的时候有q,同步下载的为q -1 ,当听到没有下载的时候,就会回退到刚开始,要求,返回头的次
数。
列方程听到t的时候,刚好听到没下载的位置。得 s + (q -1 ) * t = q * t;所以t = s;听到q * s的时候,就要回退开始,统计一下就可以了。
程序代码:
#include<iostream>
using namespace std;
int main()
{
int t,s,q,k=;
cin>>t>>s>>q;
int x=s*q;
while(x<t)
{
k++;
x=x*q;
}
cout<<k<<endl;
return ;
}
CodeForce 569A的更多相关文章
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- CodeForces 569A 第六周比赛C踢
C - C Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- codeforces 569A Music
codeforces 569A Music 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#pro ...
- Codeforce 水题报告(2)
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...
- codeforce 375_2_b_c
codeforce 375_2 标签: 水题 好久没有打代码,竟然一场比赛两次卡在边界条件上....跪 b.题意很简单...纯模拟就可以了,开始忘记了当字符串结束的时候也要更新两个值,所以就错了 #i ...
- codeforce 367dev2_c dp
codeforce 367dev2_c dp 标签: dp 题意: 你可以通过反转任意字符串,使得所给的所有字符串排列顺序为字典序,每次反转都有一定的代价,问你最小的代价 题解:水水的dp...仔细想 ...
- 三维dp&codeforce 369_2_C
三维dp&codeforce 369_2_C 标签: dp codeforce 369_2_C 题意: 一排树,初始的时候有的有颜色,有的没有颜色,现在给没有颜色的树染色,给出n课树,用m种燃 ...
- 强连通分量&hdu_1269&Codeforce 369D
强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可 ...
随机推荐
- Spring起步(一)Building a RESTful Web Service
http://spring.io/guides/gs/rest-service/ 先放链接. 这个很小很小的一个功课,我却遇到了各种各样的奇葩错误,折腾了两天才弄好. 想要开始的话,需要一些准备工具 ...
- VC++或QT下 高精度 多媒体定时器
在VC编程中,用SetTimer可以定义一个定时器,到时间了,就响应OnTimer消息,但这种定时器精度太低了.如果需要精度更高一些的定时器(精 确到1ms),可以使用下面的高精度多媒体定时器进行代码 ...
- 宣布正式发布 Windows Azure Notification Hub,新增 SQL Server AlwaysOn 可用性组侦听器支持
今天,我们非常高兴地宣布,针对使用 Windows Azure 的移动和企业开发人员推出一些新功能.这些新功能可以减少构建移动应用程序的开发时间和成本,并能帮助企业开发人员实现高可用性和全球业务连续性 ...
- API各函数作用简介
API各函数作用简介 1.控件与消息函数 AdjustWindowRect 给定一种窗口样式,计算获得目标客户区矩形所需的窗口大小 AnyPopup 判断屏幕上是否存在任何弹出式窗口 ArrangeI ...
- Spring 上下文
Spring 上下文WebApplicationContext.是服务器启动的时候加载ContextLoaderListener 的时候存在 ServletContext 中 servletConte ...
- Ajax异步请求XMLHttpRequest对象Get请求
$(function () { $("#btnGetDate").click(function () { var xhr; //第一步:创建异步请求的核心的对象: if (XMLH ...
- CD key 生成
题目描述如下: 某欧软件需要实现简易的CD-KEY算法,输入3个正整数,以空格隔开,根据者3个正整数生成的cd-key字符串.输出格式:xxxx-xxxx-xxxx-xxyy. 包含16个字符,以短划 ...
- 系统变量写在.bash_profile和.bashrc的区别
今天配置一个代理,正儿八经的把我搞蒙了,不就是export http_porxy=xxx.xxx.xxx.xxx:xxxx 然后重启服务service network restart ,依然连接不了外 ...
- UVa340 Master-Mind Hints
#include <stdio.h>#include <string.h> #define MIN(a,b) (((a) < (b)) ? (a) : (b)) int ...
- django FileFIeld和ImageField 上传路径改写
def get_file_path(instance, filename): return 'file/document/%s/%s/%s' % (instance.period.code, inst ...