Codeforces 492D - Vanya and Computer Game (二分)
来源:互联网 发布:php建站模板 编辑:程序博客网 时间:2024/05/28 15:07
题意
一只怪兽要被打X下才死,两个人的攻击频率各不同,求怪兽被谁打死。
思路
相当于第一个人y秒打一下,第二个人x秒打一下。
只要得知怪兽在第几秒被打死,就知道是被谁打死的。所以二分答案,得到怪兽惨死的时间,然后判断即可。
代码
#include <cstdio>
#include <iostream>
using namespace std;
const long long MAXN = 1e11 + 100;
int main()
{
ios::sync_with_stdio(0);
long long fx, fy, n;
cin >> n >> fx >> fy;
for (int i = 0; i < n; i++)
{
long long tmp, ans;
cin >> tmp;
long long l = 0, r = 1e15, mid;
while (l <= r)
{
mid = (l + r) >> 1;
if (mid / fx + mid / fy >= tmp)
{
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
if (ans % fx == 0 && ans % fy == 0) cout << "Both" << endl;
else if (ans % fy) cout << "Vova" << endl;
else cout << "Vanya" << endl;
}
return 0;
}
0 0
- Codeforces 492D - Vanya and Computer Game (二分)
- codeforces 492D Vanya and Computer Game (二分)
- CodeForces 492D Vanya and Computer Game [二分]
- CodeForces 492D Vanya and Computer Game(二分)
- 【1】【二分搜索】CodeForces 492D Vanya and Computer Game
- CodeForces 492D Vanya and Computer Game
- Codeforces 492D Vanya and Computer Game
- CodeForces 492D Vanya and Computer Game
- Codeforces 492D Vanya and Computer Game
- codeforces 492D. Vanya and Computer Game
- codeforces 492D Vanya and Computer Game 数论
- 492D - Vanya and Computer Game
- Codeforces Round #280 (Div. 2)D. Vanya and Computer Game(二分)
- Codeforces #280 (Div. 2)D Vanya and Computer Game (二分 + 模拟)
- D - Vanya and Computer Game
- Codeforces #280 (Div. 2)D Vanya and Computer Game
- Codeforces Round #280 (Div. 2)-D. Vanya and Computer Game
- Codeforces 492D Vanya and Computer Game 循环节找规律
- Spring学习之SpringMVC框架快速搭建实现用户登录功能
- 编程是一种美德
- Java基础之内部类、匿名类和异常处理知识点总结
- 构造函数失败
- 细说Servlet之 详解HttpServletRequest对象
- Codeforces 492D - Vanya and Computer Game (二分)
- 海思3516A hi3516A
- 十一月总结
- 细说Servlet 保存会话的技术 Session
- java中使用jdbcTemplate的query方法举例与总结
- 第14周项目6-5-输出二维数组每行最小值
- iOS绘图系列一:概述
- HDU 2096 小明A+B
- 细说Servlet-- Cookie