codeforces 811A Vladik and Courtesy

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:

题意:Vladik和Valera分别有a和b个糖,然后从Vladik开始拿1个,然后轮到Valera拿2个,然后Vladik开始拿3个,然后轮到Valera拿4个.。。。。。最后谁不能拿输出谁

分析:数据范围1e9,直接暴力i从1开始,奇数a=a-i,偶数b=b-i,谁小于0输出名字,break;

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     long long a,b;
 7     cin>>a>>b;
 8     for(int i=1;i<=10000007;i++){
 9         if(i%2==1){
10             a=a-i;
11             if(a<0) {cout<<"Vladik"<<endl;break;}
12         }
13         else{
14             b=b-i;
15             if(b<0) {cout<<"Valera"<<endl;break;}
16         }
17     }
18     return 0;
19 }
View Code
原文地址:https://www.cnblogs.com/ls961006/p/6914834.html