• 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的更多相关文章

  1. 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 ...

  2. ZOJ 3544 / HDU 4056 Draw a Mess( 并查集好题 )

    方法参见:http://blog.acmol.com/?p=751 从最后一个线段开始倒着处理(因为之后的线段不会被它之前的线段覆盖),把这条线段所覆盖的所有线段编号合并到一个集合里,并以最左边线段编 ...

  3. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  6. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  7. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  8. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  9. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

随机推荐

  1. 053 Maximum Subarray 最大子序和

    给定一个序列(至少含有 1 个数),从该序列中寻找一个连续的子序列,使得子序列的和最大.例如,给定序列 [-2,1,-3,4,-1,2,1,-5,4],连续子序列 [4,-1,2,1] 的和最大,为 ...

  2. Main函数中的参数argc,argv的使用简单解析

    本篇文章是对Main函数中的参数argc,argv的使用进行了简单的分析介绍,需要的朋友参考下: C/C++语言中的main函数,经常带有参数argc,argv,如下:  int main(int a ...

  3. Ionic开发-搭建开发环境

    1安装node.js 2安装ionic & cordova: 命令行输入:npm install –g cordova ionic 注:-g表示全局安装,也可以进入指定的目录安装,但这里推荐全 ...

  4. linq动态分页排序

    if (!string.IsNullOrEmpty(order) && !string.IsNullOrEmpty(dir))//判断排序的字段名称和排序的类型是否为空 { if (d ...

  5. AJPFX总结Java 类加载器

    顾名思义,类加载器(class loader)用来加载 Java 类到 Java 虚拟机中.一般来说,Java 虚拟机使用 Java 类的方式如下:Java 源程序(.java 文件)在经过 Java ...

  6. css3弹性伸缩和使用

    columns  分栏 column的中文意思就是栏的意思,在html中,作用是分列,把一块内容相同比例均匀的分成一块一块的列,想报纸的内容似的,一篇文章在一张内容上分成好几栏那样显示,它的属性有 1 ...

  7. 就来推荐一本2018年研究的Web书《移动Web前端高效开发实战》

    一线互联网公司Web前端团队实战经验总结,涵盖移动Web前端开发各个关键技术环节,包括移动开发核心技术.常用布局方案.MV*类新时代框架.预编译技术.性能优化.开发调试.混合式应用.单元测试.工程化等

  8. mitmweb的使用

    安装mitmproxy时带有mitmweb,可直接在命令行输入命令:mitmweb 此时可打开web界面.

  9. mui对话框、表单

    1.mui.alert() 普通提醒参数 1.message Type: String 提示对话框上显示的内容 2.title Type: String 提示对话框上显示的标题 3.btnValue ...

  10. 从wireshark数据中分析rtmp协议,并提取出H264视频流

    我写的小工具 rtmp_parse.exe 使用用法如先介绍下: -sps  [文件路径] 解析 sps 数据 文件当中的内容就是纯方本的hexstring: 如 42 E0 33 8D 68 05 ...