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时说明歌曲已经下载完成

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<algorithm>
#define ll __int64
#define mod 1000000007
#define PI acos(-1.0)
using namespace std;
int t,s,q;
int main()
{
int have=;
scanf("%d %d %d",&t,&s,&q);
have=s+s*(q-);
int ans=;
while(t>have)
{
ans++;
have=have+have*(q-);
}
cout<<ans<<endl;
return ;
}

Codeforces Round #315 (Div. 2) A 水且坑的更多相关文章

  1. Codeforces Round #315 (Div. 2) B 水题强行set

    B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  2. Codeforces Round #365 (Div. 2) A 水

    A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  4. Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  5. Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs

    A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路

    A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  7. Codeforces Round #337 (Div. 2) A水

    A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. Codeforces Round #316 (Div. 2) A 水

    A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. Codeforces Round #362 (Div. 2) A 水也挂

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

随机推荐

  1. 解决centos7 nslookup:command not found

    解析域名www.google.com时,报错,命令找不到,是因为新安装的centos7,没有安装bind-utils,安装后就可以运行nslookup了

  2. 操作表单 -------JavaScrip

    本文摘要:http://www.liaoxuefeng.com/ HTML表单的输入控件主要有以下几种: 文本框,对应的<input type="text">,用于输入 ...

  3. Java第六次作业:RuPengGame setGameSize setGameTitle alert loadBgView playSound pause closeSound confirm input createText setTextPosition setTextColor setTextFontSize hideText showText CreateImage(number)

    package com.swift; import java.awt.Color; import com.rupeng.game.GameCore;//导入游戏引擎包 //实现Runnable接口 p ...

  4. 51nod——2478 小b接水(预处理 思维)

    我本来想把每个谷都处理了,想了下觉得不好办.后来看其他人写的是处理每个位置,把每个位置可以接的水累加起来.整挺好. #include <bits/stdc++.h> using names ...

  5. Mysql 查询出某列字段 被包含于 条件数据中

    我们通常是使用  某条件  是否包含于 某列中   ,简单点 就是:select * from 表名 where  字段名 like '%条件数据%'; 现在说下   某列 被包含于 条件数据中 接下 ...

  6. 通用后台管理系统源码,响应式布局,Java管理系统源码,零门槛安装部署

    本项目是一个通用响应式管理后台,导入开发环境安装就能直接运行,界面也非诚漂亮,在PC端和移动端也是自适应的.非常适合企业或者个人搭建各种商城后台,博客后台,网站管理后台等. 源码启动后的截图 需要这套 ...

  7. 微信小程序navigator的open-type跳转问题

    navigator的open-type属性 可选值 'navigate'.'redirect'.'switchTab',对应于wx.navigateTo.wx.redirectTo.wx.switch ...

  8. Java集合---简介

    概念 集合可以理解为一个动态的对象数组,不同的是集合中的对象内容可以任意扩充.Java最基本的集合接口:Collection接口 集合的特点 性能高 容易扩展和修改 Collection的常用子类 L ...

  9. OpenCV学习笔记(九) 重映射、仿射变换

    重映射 通过重映射来表达每个像素的位置  : 这里  是目标图像,  是源图像,  是作用于  的映射方法函数.想象一下我们有一个图像  , 我们想满足下面的条件作重映射:,图像会按照  轴方向发生翻 ...

  10. OpenCV学习笔记(七) 图像金字塔 阈值 边界

    转自: OpenCV 教程 使用 图像金字塔 进行缩放 图像金字塔是视觉运用中广泛采用的一项技术.一个图像金字塔是一系列图像的集合 - 所有图像来源于同一张原始图像 - 通过梯次向下采样获得,直到达到 ...