Codeforces Round #315 (Div. 2) A. Music Problem Solving Experience

Source: Internet
Author: User

Original question:

Description

Little Lesha loves listening to music via his smartphone. But the smartphone doesn ' t has much memory, so Lesha listens to his favorite songs in a well-known social network intalk.

Unfortunately, Internet is isn't 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" has no yet been downloaded, Lesha immediately plays the song from the Start (the Loaded part of the song stays on his phone, and the download are 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 your download q -1 seconds of the track.

Tell Lesha, for how many times he'll 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 would be restarted.

Sample Input

Input
5 2 2
Output
2
Input
5 4 7
Output
1
Input
6 2 3
Output
1

Hint

In the first Test, the song is played twice faster than it's downloaded, which means that during four first seconds Lesha Reaches the moment that have not been downloaded, and starts the song again. After another-seconds, the song is downloaded completely, and thus, Lesha starts the song twice.

The second Test, the song is almost downloaded, and Lesha would start it only once.

In the third sample test, the download finishes and Lesha finishes listening at the same moment. Note that song is ' t restarted in the case.

Analysis: Basically is a math problem ok, with the mathematical formula to derive some boundary conditions

Programming is sometimes a program to solve some mathematical problems ah.

Code:

#include <iostream>#include<cstdio>#include<algorithm>using namespacestd;Const intN =200000+Ten;ints, q, t;intMain () {intCNT; CIN>> T >> s >>Q; DoubleTI = q*t/(Double) (Q-1); DoubleAns = s*Q;  for(inti =2; i < N; i++) {ans= ans + ans*Q; if(Ans >=ti) {CNT=i;  Break; }} cout<< CNT <<Endl; return 0;}

Codeforces Round #315 (Div. 2) A. Music Problem Solving Experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.