CodeForce 416 (Div. 2) A. Vladik and Courtesy

来源:互联网 发布:什么叫人工智能技术 编辑:程序博客网 时间:2024/06/08 06:42

题目链接:点击打开链接

A. Vladik and Courtesy
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ab (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.

Examples
input
1 1
output
Valera
input
7 6
output
Vladik
Note

Illustration for first test case:

Illustration for second test case:


题意属于看示例就懂的,但我还是WA一次,5分钟能搞定的事,偏偏最后加罚时用了29分钟。 注意谁先给,还要注意给了以后另一个不要,好像贪心做多了,我都跟着贪心了,把给的都要了回来,哈哈。


代码实现:

#include<iostream>#include<algorithm>using namespace std;int main(){long long m,n,count;while(cin>>m>>n){count=1;while(m>=0&&n>=0){if(count%2){m=m-count;count++;}else{n=n-count;count++;}}if(n<0)cout<<"Valera"<<endl;else if(m<0)cout<<"Vladik"<<endl;}return 0;} 


原创粉丝点击