zoukankan      html  css  js  c++  java
  • Round #416 A. Vladik and Courtesy(Div.2)

    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:

    #include <iostream>
    #include <stdio.h>
    #include <math.h>
    using namespace std;
    
    int main(){
        int a,b,x;
        scanf("%d%d",&a,&b);
        x=sqrt(a);
        x=(x*x)+x;
        if(x<=b) printf("Vladik");
        if(x>b) printf("Valera");
        return 0;
    }
    
    #include <iostream>
    #include<cstdio>
    using namespace std;
    
    int main(){
    
        int a,b;
        scanf("%d%d",&a,&b);
        int cnt=1;
        while(a>=0&&b>=0){
            a-=cnt;
            cnt++;
            b-=cnt;
            cnt++;
        }
        if(a>=0) puts("Valera");
        else puts("Vladik");
        return 0;
    }
  • 相关阅读:
    Rational Rose 2003 逆向工程转换C++ / VC++ 6.0源代码成UML类图
    用VC实现特定编辑框上对回车键响应
    22.职责链模式
    21.策略模式
    20.状态模式
    19.解释器模式
    18.备忘录模式
    17.中介者模式
    16.观察者模式
    15.迭代器模式
  • 原文地址:https://www.cnblogs.com/z-712/p/7307713.html
Copyright © 2011-2022 走看看