您的位置:首页 > 编程语言 > Go语言

Codeforces 569 A. Music ( 模拟 )

2015-08-12 15:19 417 查看
题目链接:http://codeforces.com/problemset/problem/569/A

题        意:给你一首歌的播放时间T,下载S秒后开始播放,对于任意第q秒可以下载q-1的内容(即每秒下载歌曲q-1/q秒)。

                    而播放的速度比下载的快,每当播放到没下载的地方,就好从头开始播放,问从头开始播放的次数。

思        路:模拟追击问题,设temp秒后听到没有下载的地方,得到temp*(q-1)/q + S = temp 即 temp = q*S,所以要求temp>= q*S.

代码如下:#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <stack>
#include <algorithm>
#define maxn 1179861
int main()
{
int T, S, Q;
while( scanf ( "%d %d %d", &T, &S, &Q ) != EOF )
{
int ans = 0;
while( S < T )
{
S *= Q;
ans++;
}
printf("%d\n",ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codeforces algorithm