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 you to 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.
(Explanation is to come to this Daniel's (one can understand): http://blog.csdn.net/Tc_To_Top/article/details/47424809)
The main idea: a person download the song, each Q unit can download q-1 time units of the song, the length of the song is T, down to the time to start playing, if the song has not been finished and placed in the place has not been downloaded, then start to put, ask how many times to put
Title analysis: Start from S, set the cur seconds after listening and the next progress of the same, then S + (Q-1)/q * cur = cur, solution cur = q * s, and then from the beginning, set T ' s after the same progress, then (Q-1)/q * t ' + cur = t ', solved T ' = cur * q, can be seen directly take the first progress of the same time multiply Q is the next time the same progress
The code is as follows:
1#include <stdio.h>2 intMain ()3 {4 Doublet,s,q,tin=0;5 intans=1;6scanf"%LF%LF%LF",&t,&s,&q);7 Doublexia=s*Q;8 while(xia<T)9 {Tenxia*=Q; Oneans++; A } -printf"%d\n", ans); -}
Codeforces 569A Eighth Competition c