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;
    }
  • 相关阅读:
    四个足以警醒你一生的故事!
    人们通常不知道自己想要什么,除非你秀出产品给他们看。
    有些话应该记住
    禅语
    是笑话,是悲凉,是笑后的真实,是真实后的悲凉
    vb6.0分隔文本文件读写的两个例程
    boost Serialization源码分析(1)
    养成好习惯,好气质
    日记(海子)
    关于C#的委托与事件的一个小DEMO
  • 原文地址:https://www.cnblogs.com/z-712/p/7307713.html
Copyright © 2011-2022 走看看