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",& ...
随机推荐
- 牛客网Java刷题知识点之什么是内部类、为什么要使用内部类、内部类如何使用外部类的属性和方法、成员内部类、局部内部类、静态内部类、匿名内部类
不多说,直接上干货! 可以将一个类的定义放在另一个类的定义内部,这就是内部类. 内部类是一个非常有用的特性但又比较难理解使用的特性(鄙人到现在都没有怎么使用过内部类,对内部类也只是略知一二). 内部类 ...
- Spark Mllib里的Mllib基本数据类型(图文详解)
不多说,直接上干货! Spark Mllib基本数据类型,根据不同的作用和应用场景,分为四种不同的类型 1.Local vector : 本地向量集,主要向spark提供一组可进行操作的数据集合 2 ...
- SpringCloud服务的平滑上下线
http://blog.itpub.net/31545684/viewspace-2215300/ spring cloud eureka 参数配置 https://www.jianshu.com/p ...
- String类、StringBuilder类、StringBuffer类
String类是不可变类,创建了一个String对象后,该String对象中的字符序列不能被改变. StringBuilder是字符序列可变的字符串类,提供了一系列修改字符串的方法. StringBu ...
- 缓存List并写入文件持久化
LIfe is half spent before we know what is it. 缓存List并写入文件持久化 需要缓存一个List集合,比如缓存一个输入框中用户之前输入过的内容,下次当用户 ...
- 监听textarea数值变化
监听textarea数值变化 $('#id').bind('input propertychange', function(){ //TODO });
- <Android 应用 之路> 天气预报(二)
界面组成 载入界面 显示界面 Activity两个,一个用来显示载入界面,一个用来显示天气信息 主要代码如下: public class MyActivity extends Activity { p ...
- /usr/local/sbin/fping -s www.baidu.com www.google.com
/usr/local/sbin/fping -s www.baidu.com www.google.com
- 如何清除SharePoint Server 配置缓存
日常运维中您可能需要清除SharePoint 2010/2013/2016中的过期配置缓存.例如,有时计时器作业往往会卡住,并在这种情况下清除缓存.您可以手动清除SharePoint配置缓存或者使用P ...
- python+selenium之处理alert弹出对话框
注:本篇文章转载 http://www.cnblogs.com/mengyu/p/6952774.html 在完成某些操作时会弹出对话框来提示,主要分为"警告消息框"," ...