• Codeforces Round #315 (Div. 2) A 水且坑


    A. Music
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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 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 that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is 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 will 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 will be restarted.

    Examples
    input
    5 2 2
    output
    2
    input
    5 4 7
    output
    1
    input
    6 2 3
    output
    1
    Note

    In the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.

    In the second test, the song is almost downloaded, and Lesha will start it only once.

    In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.

     题意:时长为t秒的歌曲  已经下载了s秒的歌曲  下载速度为 (q-1)/q(秒(歌曲)/秒) 

    当因为没有下载而歌曲停止播放时  从头开始听  问需要听几次歌 才能下载完成

     题解:设x为停止播放的时间点  

              x=s+x*(q-1)/q 

      推出   x=s*q

              当t<=x时说明歌曲已经下载完成

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<queue>
     5 #include<stack>
     6 #include<vector>
     7 #include<map>
     8 #include<algorithm>
     9 #define ll __int64
    10 #define mod 1000000007
    11 #define PI acos(-1.0)
    12 using namespace std;
    13 int t,s,q;
    14 int main()
    15 {
    16     int have=0;
    17     scanf("%d %d %d",&t,&s,&q);
    18     have=s+s*(q-1);
    19     int  ans=1;
    20     while(t>have)
    21     {
    22         ans++;
    23         have=have+have*(q-1);
    24     }
    25     cout<<ans<<endl;
    26     return 0;
    27 }
  • 相关阅读:
    oracle之数据限定与排序
    oracle之分组函数
    oracle之SQL的数据类型
    lftp简单使用
    黑盘-蓝盘-绿盘-红盘
    windows 路由
    http扩展请求头中的x-Forwarded-For
    http状态码304
    firewall 实现数据的端口转发
    通过curl获取网页访问时间
  • 原文地址:https://www.cnblogs.com/hsd-/p/5689708.html
Copyright © 2020-2023  润新知