codeforces 569A Music
codeforces 569A Music 解题报告
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88890#problem/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
Sample Output
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.
题目大意:
一首歌共有t秒,下载s秒后开始播放,边播边下,每q秒可以下载这首歌的(q-1)秒,每当播到未下载的部分时,返回从头开始播放。问下载这首歌需要从头开始播放多少次。
分析:
刚开始看这道题的时候完全不懂这是在干什么。
假设放到未下载点的时候用时x秒,每秒的下载速度(q-1)/q,x=s+x*(q-1)/q,则x=s*q。
代码:
#include<cstdio>
#include<iostream>
using namespace std; int main()
{
int t,s,q;
int m=;
scanf("%d%d%d",&t,&s,&q);
while(s<t)//判断是否播完
{
s=s*q;
m++;
}
printf("%d\n",m);
return ;
}
codeforces 569A Music的更多相关文章
- CodeForces 569A 第六周比赛C踢
C - C Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- codeforces 569A A. Music(水题)
题目链接: A. Music time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- 【30.49%】【codeforces 569A】Music
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 569A 第八次比赛 C题
Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...
- Codeforces Round #315 (Div. 2A) 569A Music (模拟)
题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- Changing the Auto-Logout Timeout in SSH
SSH: We can set a timeout interval for ssh client who are idle or in inactive state. As soon as the ...
- BZOJ 1103 [POI2007]大都市meg(树状数组+dfs序)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1103 [题目大意] 给出一棵树,每条边的经过代价为1,现在告诉你有些路不需要代价了, ...
- Oracle 生成指定范围内随机日期
Oracle生成一个指定范围内的随机日期 /* 年1月1日)的整数偏移量来保存(即把日期保存为一个数字); * 因此可通过寻找‘指定日期’与‘关键日期’相对应的整数偏移量,再加一个指定范围内的随机整数 ...
- jsp 有哪些内置对象?作用分别是什么? 分别有什么方 法?
JSP共有以下9种基本内置组件 request对象 客户端请求,此请求包含来自GET/POST的请求参数,通过它才能了解到客户的需求,然后做出相应. response对象 ...
- JavaSE复习日记 : 八种基本数据类型
/* * 基本数据类型 * * Java里的8种基本数据类型: * byte --- 1 byte = 8 bit; * short --- 2 byte = 16 bit; * int --- 4 ...
- nodebeginer
最近对node开始感兴趣,知乎上朴灵推荐入门书籍,goddy翻译的node beginner. 貌似大家对深入浅出node.js评价都不错,以后可以考虑入手看看. 一口气看完了node beginne ...
- https tomcat 证书搭建
首先生成证书说明 keytool -genkey -alias castest -keyalg RSA -keystore c:/keys/caskey 先让输入密码,密码必须记住,下面会用到 其中“ ...
- wireshark 包分析命令
1.查看原地址过滤包命令: ip.src ==192.168.1.1 2.查看目的地址过滤包:ip.dst == 192.168.1.1 3.关键字 eq 等于 "==" ,and ...
- DM368 arm板GDB远程调试
参考: http://www.erchashu.com/wiki/eclipse-cdt-gdb-arm-app-cross-debug 远程调试环境由宿主机GDB和目标机调试stub共同构成,两者通 ...
- IOS 学习笔记(7) 控件 分隔栏控件(UISegmentControl)的使用方法
分隔栏控件的系统默认式样一共有3种,分别是“普通式样”,"边框式样","条状式样" 分隔栏控件中有一个momentary属性,默认时NO.当开发者配置成YES时 ...