Codeforces Round #315 (Div. 2) 569A Music (類比)

來源:互聯網
上載者:User

標籤:

題目: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 }

 

Codeforces Round #315 (Div. 2) 569A Music (類比)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.