CodeForces - 811A
2017-08-08 20:04
411 查看
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.
Input
Single line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of
Vladik and Valera candies respectively.
Output
Pring a single line "Vladik’’ in case, if Vladik first who can’t give right amount of candy, or "Valera’’ otherwise.
Example
Input
Output
Input
Output
代码:
#include <iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
int n,m;
int main(){
cin>>n>>m;
int k=1;
while(1)
{
if(n>=k)n=n-k;else {cout<<"Vladik"<<endl;break;}
k++;
if(m>=k)m=m-k;else {cout<<"Valera"<<endl;break;}
k++;
}
return 0;
}
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.
Input
Single line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of
Vladik and Valera candies respectively.
Output
Pring a single line "Vladik’’ in case, if Vladik first who can’t give right amount of candy, or "Valera’’ otherwise.
Example
Input
1 1
Output
Valera
Input
7 6
Output
Vladik
代码:
#include <iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
int n,m;
int main(){
cin>>n>>m;
int k=1;
while(1)
{
if(n>=k)n=n-k;else {cout<<"Vladik"<<endl;break;}
k++;
if(m>=k)m=m-k;else {cout<<"Valera"<<endl;break;}
k++;
}
return 0;
}
相关文章推荐
- Vladik and Courtesy - CodeForces - 811A
- CodeForces - 510B Fox And Two Dots(DFS)
- 【CodeForces】678A - Johny Likes Numbers
- codeforces 12E - Start of the session
- CodeForces - 514A Chewbaсca and Number
- Codeforces 22B Bargaining Table
- codeforces - 707B - Bakery(图的遍历)
- Codeforces 848C. Goodbye Souvenir
- Problem--82A--Codeforces--Double Cola
- CodeForces-820D Mister B and PR Shifts
- codeforces 327
- Codeforces 551B ZgukistringZ (字符串处理)
- codeforces 688C C. NP-Hard Problem(bfs判断奇数长度环)
- CodeForces 687A NP-Hard Problem 搜索
- CodeForces-Round235D
- CodeForces - 633B A Trivial Problem(找规律)
- Codeforces 812B-Sagheer, the Hausmeister
- Codeforces 295B——Flody算法求最短路径
- Codeforces 235C. Cyclical Quest 后缀自动机
- codeforces 685A (水题)