Codeforces Round #280 (Div. 2)D. Vanya and Computer Game(二分)
2015-12-02 11:29
375 查看
题目链接
题意:A,B俩人一起打怪,A一秒打X次,B一秒打Y次,(每个人的攻击是对所有的怪物都有效果),每个怪物被打ai下就会死掉,问最后一下是谁打的。
解法 :A打一次是1/X 秒
B打一次是1/Y秒,浮点数不好计算,我们把二者乘以XY,那么
A打一次就是Y秒,B打一次就是X秒。然后二分怪物被打死的时间t.条件是t/X+t/Y>=a
题意:A,B俩人一起打怪,A一秒打X次,B一秒打Y次,(每个人的攻击是对所有的怪物都有效果),每个怪物被打ai下就会死掉,问最后一下是谁打的。
解法 :A打一次是1/X 秒
B打一次是1/Y秒,浮点数不好计算,我们把二者乘以XY,那么
A打一次就是Y秒,B打一次就是X秒。然后二分怪物被打死的时间t.条件是t/X+t/Y>=a
#define CF #ifndef CF #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<string> #include<iostream> #include<set> #include<vector> #else #include<bits/stdc++.h> #endif // CF using namespace std; #define LL long long #define pb push_back #define X first #define Y second #define cl(a,b) memset(a,b,sizeof(a)) typedef pair<long long ,long long > P; const int maxn=100005; const LL inf=1LL<<60; const LL mod=1e9+7; int main(){ LL n,x,y; cin>>n>>x>>y; for(int i=0;i<n;i++){ LL a;cin>>a; LL l=0,r=1LL<<62; while(l<=r){ LL mid=(l+r)/2; if(mid/x+mid/y>=a)r=mid-1; else l=mid+1; } if(l%x==0&&l%y==0)puts("Both"); else if(l%y==0)puts("Vanya"); else puts("Vova"); } return 0; }
相关文章推荐
- Nginx安装及配置文件nginx.conf详解
- Hexagon SDK之Audio CAPI详解
- SQL的Case When ... Then ... Else ... End... 语句
- elasticsearch 安装
- git 错误 fatal: Not a valid object name: 'master'.
- Nginx 反向代理并缓存及缓存清除
- Linux ALSA声卡驱动之一
- 利用viewpager实现图片左右循环滑动效果
- javascript实现自动填写表单实例简析
- ORACLE删除当前用户下所有的表的方法
- PyQt4在spyder中使用,程序只能运行一次,第二次运行报错:It seems the kernel died unexpectedly. Use 'Restart kernel' to cont
- Adding a CoAP app
- 大数据 | 数据挖掘 | R语言 R绘图Session#1 - 基础
- lua学习 settable
- copy,retain,assign,strong,weak的区别
- ArcGIS教程:欧氏分配 (空间分析)
- iOS uibutton 上下按钮样式
- C-022.数组的基本概念和初始化介绍
- ios 中的UIApplication类以及直接打开iPhone的设置页面
- IntelliJ Idea / Android Studio 常用快捷键列表