zoj 4056


At 0 second, the LED light is initially off. After BaoBao presses the button 2 times, the LED light turns on and the value of the counter changes to 1. The value of the timer is also set to 2.5 seconds. After DreamGrid presses the button 1 time, the value of the counter changes to 2.
At 2.5 seconds, the timer counts down to 0 and the LED light is off.
At 5 seconds, after DreamGrid presses the button 1 time, the LED light is on, and the value of the timer is set to 2.5 seconds.
At 7.5 seconds, the timer counts down to 0 and the LED light is off.
At 8 seconds, after BaoBao presses the button 2 times, the LED light is on, the value of the counter changes to 3, and the value of the timer is set to 2.5 seconds.
At 10 seconds, after DreamGrid presses the button 1 time, the value of the counter changes to 4, and the value of the timer is changed from 0.5 seconds to 2.5 seconds.
At 12.5 seconds, the timer counts down to 0 and the LED light is off.
At 15 seconds, after DreamGrid presses the button 1 time, the LED light is on, and the value of the timer is set to 2.5 seconds.
At 16 seconds, after BaoBao presses the button 2 times, the value of the counter changes to 6, and the value of the timer is changed from 1.5 seconds to 2.5 seconds.
At 18 seconds, the game ends.
只要遇到a,c的倍数就会按b,d次按钮,若同是a,c的倍数,先a,后c
若按之前为暗,按一次变亮,若按之前为亮,按一次为计数器+1
每次按一下,都会让计时器重新设置为v+0.5(开始倒计时,时间到0,就会变暗)
问[0,t]的时间内,计数器最后为多少。(0为任意数的倍数)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
int T;
ll a,b,c,d,v,t;
ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
return a*b/gcd(a,b);
}
ll x,y,z,cnt,ans,last;
/*
明显一个最小公倍数为一个周期
0 :单独算
再计算除一个周期的结果*周期数
再加上不满一个周期的结果
*/
int main()
{
scanf("%d",&T);
while(T--){
scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&v,&t);
ans=b+d-;
x=,y=,last=,cnt=;//ans 不用再赋初值了
/* */
z=lcm(a,c);//(a,c) 不是(x,y)
while(x<z||y<z){
if(x+a<=y+c){
x+=a;
if(x<=last+v) cnt++;
cnt+=b-;
last=x;
}
else{
y+=c;
if(y<=last+v) cnt++;
cnt+=d-;
last=y;
} }
ans+=cnt*(t/z);//cnt为一个周期的结果
t%=z;
x=,y=,last=;
while(x+a<=t||y+c<=t){//保证在t的范围内
if(x+a<=y+c){
x+=a;
if(x<=last+v) ans++;
ans+=b-;
last=x;
}
else{
y+=c;
if(y<=last+v) ans++;
ans+=d-;
last=y;
}
}
printf("%lld\n",ans);
}
return ;
}
zoj 4056的更多相关文章
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
A Live Love DreamGrid is playing the music game Live Love. He has just finished a song consisting of ...
- ZOJ 3544 / HDU 4056 Draw a Mess( 并查集好题 )
方法参见:http://blog.acmol.com/?p=751 从最后一个线段开始倒着处理(因为之后的线段不会被它之前的线段覆盖),把这条线段所覆盖的所有线段编号合并到一个集合里,并以最左边线段编 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
随机推荐
- 关于byte[]和字符串的转换
public static String byteToStr(byte[] b) { return new String(b); } public static byte[] strToByte(St ...
- Storm概念学习系列之并行度与如何提高storm的并行度
不多说,直接上干货! 对于storm来说,并行度的概念非常重要!大家一定要好好理解和消化. storm的并行度,可以简单的理解为多线程. 如何提高storm的并行度? storm程序主要由spout和 ...
- jvm 内存dump、gc查看、线程死锁,jmap、jstack、jstat
1. jstat 这个命令对于查看Jvm的堆栈信息很有用.能够查看eden,survivor,old,perm等heap的capacity,utility信息 对于查看系统是不是有能存泄漏以及 ...
- 13.JAVA-包package、import使用
1.包的定义 之前我们学习java时,生成的class文件都是位于当前目录中,假如出现了同名文件,则会出现文件覆盖问题,因此就需要设置不同的目录(定义包),来解决同名文件冲突问题. 并且在大型项目中, ...
- 【Java】 hashcode()和System.identityHashCode()
hashcode()和System.identityHashCode() openjdk8: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/5b86f ...
- C++ 中函数后面跟const是什么意思
问题:c++:void display( ) const 中的const是什么意思?简答:意思是除了表明了mutable的成员变量以外该类的其他的成员变量在这个函数内一律不能修改. 详细:加const ...
- Android Doze模式源码分析
科技的仿生学无处不在,给予我们启发.为了延长电池是使用寿命,google从蛇的冬眠中得到体会,那就是在某种情况下也让手机进入类冬眠的情况,从而引入了今天的主题,Doze模式,Doze中文是打盹儿,打盹 ...
- Azure 镜像市场支持一键部署到云
本视频教程介绍了Azure 镜像市场和一键部署到云. Azure 镜像市场(AMP)由世纪互联运营,是一个联机应用程序和服务市场,它通过独立软件服务商(ISV)能够成为 Azure 客户(Custom ...
- BandwagonHost 5个数据中心/机房Ping速度测试亲自体验
我们选择Bandwagonhost服务器的原因之一在于有5个数据中心,而且与众多其他VPS不同之处在于可以自己后台切换机房和IP,这样我们 在遇到不满意的速度时候,可以自己切换其他机房更换,而且对于有 ...
- CF 55D Beautiful numbers (数位DP)
题意: 如果一个正整数能被其所有位上的数字整除,则称其为Beautiful number,问区间[L,R]共有多少个Beautiful number?(1<=L<=R<=9*1018 ...