Codeforce round #315 A music
来源:互联网 发布:哈利波特魔杖淘宝 编辑:程序博客网 时间:2024/05/18 00:46
模拟水题
题意:边放边下载一首歌,由于网速太慢,当播放到还没下载的地方,主人公就会从头开始放,给三个输入,这首歌总长T,已经下好的S,播放的间接速度Q,因为这里的Q的意思是下载Q-1部分等于播放Q部分的时间,问主人公到底要从头开始播放几遍,第一遍也算。
话说这题,开始思路当成初中数学追击问题 还给想错了,最初的几个数据过了,最终测试没过 导致 惨淡cf div2 第二场爆1题 掉分到绿名。。。
赛后看了别人简略做法。。。想了很久。。。这是div2 的A啊
设一个变量t 当播放和下载位置重逢时满足, Q*t=(Q-1)*t+S;
简化得t=S;
而Q和Q-1并不是速度,所以实际上这里t的定义是下载 以Q-1变化,播放以Q变化时在不同的S前提下能让下载和播放相等的那个点。
所以,这里思路就是模拟 每一个点变化时,播放有没有到达 下载的位置。
#include<bits/stdc++.h>using namespace std;int main(){int T,S,Q; while(~scanf("%d %d %d",&T,&S,&Q)) { int cnt=1,nowd=0,nowp=0; for(int i=S+1;i<=T;i++) { nowd=i*(Q-1); nowp+=Q; if(nowp>=nowd) { if(i==T&&nowd==nowp) continue; cnt++; nowp=0; } } printf("%d\n",cnt); }}
拖延症患者,不好意思说这是这个假期做的为数不多的题,算法还没撸起来….假期没了#勿忘初心#cheering up
0 0
- Codeforce round #315 A music
- A. Music-Codeforces Round #315 (Div. 2)
- Codeforces Round #315 (Div. 2) A. Music
- Codeforces Round #315 (Div. 2) A. Music
- Codeforces Round #315 (Div. 2)A. Music
- Codeforces Round #315 (Div. 2)569A Music(模拟)
- Codeforces Round #315 div2 A--Music 水题可结合数学推导
- Codeforces Round #315 (Div. 2) A. Music (模拟)
- Codeforces Round #315 (Div. 2)569A Music(模拟)
- codeforce round A. Binary Protocol
- codeforce round 170 A. Learning Languages
- CodeForce 659A - Round House(水题)
- CodeForce Round #479 A. Karen and Morning
- Codeforce Round #422(Div 2) A
- Codeforce Round #382 (div 1) A
- Codeforce Round #383(Div 1) A
- Codeforce Round #384(Div 2)A
- Codeforce Round #439 A B C 题解
- UVA 10986Sending email 【dijkstra + 堆优化】
- 连载《一个程序猿的生命周期》-26.组建项目团队
- TCP三次握手及其背后的缺陷
- zoj3279 简单二分
- UIScrollView
- Codeforce round #315 A music
- initBinder,对日期修改
- Java Thread的interrupt详解
- 重写ListView的Adapter时,getView()方法没有执行的原因
- oracl数据库的常用知识
- UITableView
- js基础1
- ImageLoad(二)
- mysql修改默认的环境的字符集为utf-8