• 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;
    }
  • 相关阅读:
    Windows10 ntoskrnl.exe占用大量的磁盘空间(100%)
    Windows10 正式企业版激活
    edit-distance
    climbing-stairs
    minimum-path-sum
    unique-paths-II
    unique-paths
    剑指 Offer 42. 连续子数组的最大和
    剑指 Offer 54. 二叉搜索树的第k大节点
    矩阵中的路径
  • 原文地址:https://www.cnblogs.com/z-712/p/7307713.html
Copyright © 2020-2023  润新知