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;
    }
  • 相关阅读:
    MYSQL数据库常用语句
    node.js(http协议)
    web 后端规范与思想
    linux系统下开启一个简单的web服务
    linux基础学习之软件安装以及常用命令(三)
    Vue如何使用动态刷新Echarts组件
    linux基础学习之软件安装以及常用命令
    linux基础学习
    浅谈FIle协议与Http协议及区别
    vueJs的简单入门以及基础语法
  • 原文地址:https://www.cnblogs.com/z-712/p/7307713.html
Copyright © 2011-2022 走看看