Codefoces-811A Vladik and Courtesy [模拟]
来源:互联网 发布:淘宝旺铺助手 编辑:程序博客网 时间:2024/06/08 05:38
At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.
More formally, the guys take turns giving each other one candy more than they received in the previous turn.
This continued until the moment when one of them couldn’t give the right amount of candy. Candies, which guys got from each other, they don’t consider as their own. You need to know, who is the first who can’t give the right amount of candy.
Single line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of Vladik and Valera candies respectively.
Pring a single line "Vladik’’ in case, if Vladik first who can’t give right amount of candy, or "Valera’’ otherwise.
1 1
Valera
7 6
Vladik
Illustration for first test case:
Illustration for second test case:
题意
对A和B两个数轮流操作,第i轮对A删除2*i-1的值,对B删除2*i的值,问哪个谁先小于0? A先手。
只需要根据等差数列求和列出两个不等式即可:
对于A来说,直到第i轮消耗的数量为:i*i<=a
对于B来说,直到第i轮消耗的数量为:i*(i+1)<=b
因此,只要求最大的ia和ib即可,二者中小的先消耗光,而相等的时候答案就输出A,因为A先手。
#include <bits/stdc++.h>#define ll long longusing namespace std;ll a,b,x,y;int main() {cin>>a>>b;for(x=0;x*x<=a;x++);for(y=0;y*(y+1)<=b;y++);if(x<=y) cout<<"Vladik";else cout<<"Valera";return 0;}
- Codefoces-811A Vladik and Courtesy [模拟]
- A. Vladik and Courtesy
- A. Vladik and Courtesy
- A. Vladik and Courtesy
- Codeforces 811A Vladik and Courtesy
- codeforces 811A Vladik and Courtesy
- Codeforces 811 A Vladik and Courtesy
- CodeForces 811A ——Vladik and Courtesy——暴力,模拟
- codeforces——811A——Vladik and Courtesy
- codeforces #416 div2 811A-Vladik and Courtesy
- A. Vladik and Courtesy(思维题)
- Vladik and Courtesy
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- CodeForce 416 (Div. 2) A. Vladik and Courtesy
- #416 Div.2 A. Vladik and Courtesy-water
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- A. Vladik and flights
- 剑指offer 面试题24 二叉搜索树的后序遍历序列
- XML约束
- Magento 2中文手册教程
- weka之调用特征选择
- Android中checkbox全选功能的简单实现
- Codefoces-811A Vladik and Courtesy [模拟]
- Magento 2中文手册教程
- FragmentDialog横屏全屏
- PhotoShop cc 2017安装 zeplin插件
- 用宏定义来完成运算(本文来自百度文库)
- JS
- Mac xelatex
- Java 5*5数组的三种排列例子
- 创新实训5.28 代码转交&实时评测