CodeForces - 569A Music

题目链接

这就是一道数学题;

歌曲总时间:T;

已下载时间:S;

每Q秒能下载Q-1秒的歌曲;

所以1s损失(1-(q-1)/q)个时间;

所以S=(1-(q-1)/q)*t  ==> t=S*q;

所以代码

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int T,S,Q;
    int t=0;
    while(~scanf("%d%d%d",&T,&S,&Q))
    {   t=0;
        while(S<T)
        {
            S=S*Q;
            ++t;
        }
        cout<<t<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_40941611/article/details/82747888