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

题目:Click here

题意:(据说这个题的题意坑了不少人啊~~~)题目一共给了3个数---- T 表示歌曲的长度(s)S 表示下载了歌曲的S后开始第一次播放(也就是说S秒的歌曲是事先下载好的)、q 表示下载速度(每秒下载歌曲(q-1)/q秒)。问题就是播放的速度比下载的速度慢,每当播放到没下载的位置,就会重新从头播放,输出的就是从头播放的次数(包括第一次)

分析:高中物理追击问题,模拟下好了。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const double EPS=1e-8;
 4
 5 double T, S, q;
 6 int main()  {
 7     while( ~scanf("%lf%lf%lf", &T, &S, &q ) )  {
 8         double dlpos = S;
 9         double dlspeed = (q-1)/q;
10         double plspeed = 1.0;
11         int ret = 0;
12         while( dlpos < T )  {   // 当下载位置到达T时再次播放一定结束了
13             double reachtime = dlpos/(plspeed-dlspeed);
14             dlpos = reachtime;
15             ret++;
16             if( fabs(dlpos - T) < EPS ) // 当恰好下载与播放同时到了歌曲最后结束,就跳出循环,不进行下次播放
17                 break;
18         }
19         printf("%d\n", ret );
20     }
21     return 0;
22 }
时间: 2024-08-09 02:04:00

Codeforces Round #315 (Div. 2) 569A Music (模拟)的相关文章

Codeforces Round #315 (Div. 1)

A. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and un

Codeforces Round #259 (Div. 2) (简单模拟实现题)

题目链接:http://codeforces.com/problemset/problem/454/A A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine

Codeforces Round #327 (Div. 2) B. Rebranding 模拟

B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the

2017-4-29-Train:Codeforces Round #315 (Div. 2)

A. Music(数学题) 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

Codeforces Round #315 (Div. 2) C - Primes or Palindromes?(暴力打表)

题意:给一个p和q然后求π(n)?≤?p/q*rub(n),的最大的n值,其中π(n)?表示从1到n之间的素数的个数, rub(n)表示从1到n之间的回文数的个数(回文数不能有前导0,且从左到右和从右到左一样) 分析:其实这题没有题目没有确定n的范围让人不敢直接暴搜打表,但是你只要手动写个函数y=π(n)?/rub(n) 手动模拟暴力一下就可以发现其实这个函数大概是先下降后上升的,由于1/42<=p/q<=42,也就是说当y=42的时候就 是它的边界了,那么n的范围大概是1200000左右,取

Codeforces Round #552 (Div. 3)-1154E-Two Teams-(模拟+双指针)

http://codeforces.com/contest/1154/problem/E 解题: 举例n=10,k=1 1,2,10,4,7,6,9,8,5,3 第一次,1队先挑2,10,4这三个人 1,2,10,4,7,6,9,8,5,3 第二次,2队挑6,9,8三个人 1,2,10,4,7,6,9,8,5,3 第三次,1队挑1,7,5三个人 1,2,10,4,7,6,9,8,5,3 第四次,2队挑3一个人 1,2,10,4,7,6,9,8,5,3 显然需要实现的有两点 (1)挑完后的“连接”

Codeforces Round #315 (Div. 2)

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 E

Codeforces Round #315 (Div. 2) A. Music 解题心得

原题: 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

Codeforces Round #315 (Div. 2) (ABCD题)

A. Music 题意: 一首歌长度为S秒,已经下载了T秒,下载速度为每q秒的现实时间能下载下来(q-1)秒 的歌曲.现在开始听歌,如果听到还没下载的地方就从0秒的地方开始replay,求一首歌听完需要从0秒听几次(包括一开始那次) 思路: 我们可以用路程-时间的思路来考虑这道题. 假设两位选手"播放"与"下载","播放"的起点是0m处,"下载"的起点是Tm处,终点在Sm处,"播放"的速度是1m/s,&qu