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

 

Input
5 2 2
Output
2
Input
5 4 7
Output
1
Input
6 2 3
Output
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的更多相关文章

  1. CodeForces 569A 第六周比赛C踢

    C - C Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. codeforces 569A A. Music(水题)

    题目链接: A. Music time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  3. 【30.49%】【codeforces 569A】Music

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CodeForces 569A 第八次比赛 C题

    Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...

  5. Codeforces Round #315 (Div. 2A) 569A Music (模拟)

    题目:Click here 题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s).S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的) ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. Russia

    一.莫斯科 Moscow(Москва) 24日-周四(Day1) 1.广州 9:30公园前地铁站内集合,10:30分到达白云机场(CAN机场),12:50起飞. 18:20经停乌鲁木齐(URC机场) ...

  2. Eclips入门教程

    1. 插件推荐 Eclipse默认情况下是一个纯净版的,所以功能简单,而开源IDE最为强大的莫过于各种插件,通过使用插件可以帮助我们减少大量编写代码的工作量,也帮助我们降低了编写代码的难度,所以懂得安 ...

  3. 《Orange'S:一个操作系统的实现》笔记(一)

    感觉自己对于操作系统始终没有一个清楚的概念,尤其最近困扰于实模式.保护模式以及寻址方式等一些概念.转而一想,所有的程序,最终都是操作的计算机资源,需要和操作系统打交道,所以操作系统有必要深入了解一下. ...

  4. 阿里云ECS每天一件事D9:nginx1.7整合tomcat8.0

    仅通过8080端口访问jsp显然不是一算是一个太好的方法,可以使用nginx的proxy_pass子模块,实现nginx转发jsp请求至tomcat. 典型的配置如下: server { listen ...

  5. 一、ThinkPHP的介绍

    一.ThinkPHP的介绍 //了解 MVC M - Model 模型 工作:负责数据的操作 V - View 视图(模板) 工作:负责前台页面显示 编写html代码 C - Controller 控 ...

  6. BZOJ 2252: [2010Beijing wc]矩阵距离

    题目 2252: [2010Beijing wc]矩阵距离 Time Limit: 10 Sec  Memory Limit: 256 MB Description 假设我们有矩阵,其元素值非零即1 ...

  7. Java图形化界面设计——容器(JFrame)

    Java图形化界面设计——容器(JFrame) 程序是为了方便用户使用的,因此实现图形化界面的程序编写是所有编程语言发展的必然趋势,在命令提示符下运行的程序可以让我们了解java程序的基本知识体系结构 ...

  8. 使用java API查询java类

    一.java API的下载地址 前面列举了常用的java类,但只是介绍了功能,具体详细的用法(比如要知道该类的属性和方法)要需要调用java的API(Application Program Inter ...

  9. TCP各种连接状态注释

    TCP各种连接状态注释  连接进程是通过一系列状态表示的,这些状态有:LISTEN,SYN-SENT,SYN-RECEIVED,ESTABLISHED,FIN-WAIT-1,FIN-WAIT-2,CL ...

  10. 传统web和mvc的区别