CodeForces 569A 第六周比赛C踢
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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.
题解:
题目大意:一个人下载歌,每q个时间单位能下载q-1个时间单位的歌,歌的长度为T,下到S的时候开始播放,如果歌还没下完且放到了还未下载的地方,则重头开始放,问一共要放多少次
题目分析:一开始从s开始,设下了cur秒后听和下的进度相同,则 s + (q - 1) / q * t = t,解得t = q * s,然后从头开始,设t'秒后进度相同,则(q - 1) / q * t' + cur = t',解得t' = t* q,可见直接拿第一次进度相同的时间乘q就是接下来每次进度相同的时间
#include <iostream>
using namespace std;
int main()
{
long long t,s,q,total=;
cin>>t>>s>>q;
if(t<=s) cout<<""<<endl;
else
{
while(t>s)
{
s=s*q;
total++;
}
}
cout<<total-<<endl; }
CodeForces 569A 第六周比赛C踢的更多相关文章
- CodeForces 478B 第六周比赛B题
B - B Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descriptio ...
- Codeforces 559A 第六周 O题
Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...
- CodeForces 569A 第八次比赛 C题
Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...
- LightOJ 1317 第六周比赛A题
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description Y ...
- HUAS 2017暑假第六周比赛-题解
A.Parenthesis 括号匹配的问题有一种经典的做法. 将左括号看成1,右括号看成-1,做一遍前缀和sum. 括号序列是合法的当且仅当\(sum[n]=Min(sum[1],sum[2].... ...
- 【FOL】第六周
最近太忙,三周(第四.五.六周)一起记录一下. 1.完成了键盘的输入,顺便把之前鼠标输入改了一下(最早是在渲染循环里面处理鼠标事件) 2.UI控件方面,做了个Edit控件,把之前的Label.Imag ...
- 20145213《Java程序设计学习笔记》第六周学习总结
20145213<Java程序设计学习笔记>第六周学习总结 说在前面的话 上篇博客中娄老师指出我因为数据结构基础薄弱,才导致对第九章内容浅尝遏止地认知.在这里我还要自我批评一下,其实我事后 ...
- 20145304 Java第六周学习报告
20145304<Java程序设计>第六周学习总结 教材学习内容总结 1.InputStream与OutputStream: 在Java中,输入串流的代表对象为java.io.InputS ...
- 20145330第六周《Java学习笔记》
20145330第六周<Java学习笔记> . 这周算是很忙碌的一周.因为第六周陆续很多实验都开始进行,开始要准备和预习的科目日渐增多,对Java分配的时间不知不觉就减少了,然而第十和十一 ...
随机推荐
- [Sequence Alignment Methods] Dynamic time warping (DTW)
本系列介绍几种序列对齐方法,包括Dynamic time warping (DTW),Smith–Waterman algorithm,Cross-recurrence plot Dynamic ti ...
- 读《细说php》,php要点随记
近期读<细说php>,其实知识要点都接触过,体会下不同书籍对相同知识的描述差异,达到温故知心的目的. 未按章节顺序读,所谓要点并不是提纲式的所有要点,只是自己觉得工作中很重要(但是掌握的不 ...
- 菜鸟成长日记之新手备忘录-IOS开发第一个项目总结
2013年5月3号,开始找IOS开发工作(自学了大半年,做了一个功能不全的Demo,该出去见见世面了!),5月4号面试了第一家公司(是家刚成立一段时间的外包公司),5月5号第一家公司已二轮电话面试,5 ...
- PHP学习之[第06讲]数组、多维数组和数组函数
一.数组 ①Array(“aa”,12,true,2.2,”test”,50); ②Array(“title”=>“aa”, ”age”=>20); 1.创建: $arr= array( ...
- Spring Boot(spring mvc升级版)
周末挤出了一些时间,学了点东西,总结了一下,可能还有自己理解不到位的地方,希望大家一起交流学习,好东西要大家一起分享嘛~.时间有点紧张,所以样式没有来及做很好的调整,大家就凑活着看吧. Spring ...
- Swift: The Basics
Swift是类型安全的语言: Swift introduces optional types, which handle the absence of a value. Optional say ei ...
- iOS教你轻松打造瀑布流Layout
前言 : 在写这篇文章之前, 先祝贺自己, 属于我的GitHub终于来了. 这也是我的GitHub的第一份代码, 以下文章的代码均可以在Demo clone或下载. 欢迎大家给予意见. 觉得写得不错的 ...
- 零基础学习云计算及大数据DBA集群架构师【企业级运维技术及实践项目2015年1月29日周五】
LNMP/LEMP项目搭建 { 项目框架 # Linux_____WEB_____PHP_____DB # rhel7_____apache__-(libphp5.so)-__php__-(php-m ...
- POJ 1655 Balancing Act&&POJ 3107 Godfather(树的重心)
树的重心的定义是: 一个点的所有子树中节点数最大的子树节点数最小. 这句话可能说起来比较绕,但是其实想想他的字面意思也就是找到最平衡的那个点. POJ 1655 题目大意: 直接给你一棵树,让你求树的 ...
- Python简易爬虫
经常需要下载论文,每次都需要去网页上搜索,然后点击下载,实在麻烦,正好最近刚入门Python,心血来潮,想着写一个爬虫 经过一天查阅资料,基本算是完成了,但是还是不足,比如对知网和万方暂时还不行,但是 ...