A. Vladik and Courtesy
来源:互联网 发布:图片上传到淘宝变模糊 编辑:程序博客网 时间:2024/06/08 11:05
A. Vladik and Courtesy
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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 a, b (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
一道简单的思维题,暴力即可,没有任何 的算法。
题目大意:两个人,A有n个糖,B有m个糖,从A开始,A给B一块糖,B给A 2块糖
,依次类推,直到谁没有能力拿出足够的糖。
思路,n-减奇数,m-偶数,没减一次判断是否小于0,若小于0,则输出此人的名称。
代码如下:
#include<cstdio>#include<iostream>using namespace std;int main (){ int n,m; while(~scanf("%d%d",&n,&m)) { int i; for(i=1;;i++) { n=n-2*i+1; if(n<0) { printf("Vladik\n"); break; } m=m-2*i; if(m<0) { printf("Valera\n"); break; } } } return 0;}
若有更好的办法,可以留言哦
- A. Vladik and Courtesy
- A. Vladik and Courtesy
- A. Vladik and Courtesy
- Codefoces-811A Vladik and Courtesy [模拟]
- Codeforces 811A Vladik and Courtesy
- codeforces 811A Vladik and Courtesy
- Codeforces 811 A Vladik and Courtesy
- A. Vladik and Courtesy(思维题)
- Vladik and Courtesy
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- CodeForce 416 (Div. 2) A. Vladik and Courtesy
- #416 Div.2 A. Vladik and Courtesy-water
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy
- codeforces——811A——Vladik and Courtesy
- codeforces #416 div2 811A-Vladik and Courtesy
- CodeForces 811A ——Vladik and Courtesy——暴力,模拟
- A. Vladik and flights
- C++ 全局变量、局部变量、静态全局变量、静态局部变量的区别
- Color the ball
- LeetCode (Unique Binary Search Trees)
- 编译原理:素短语、短语、直接短语、句柄的基本概念
- Jenkins初识
- A. Vladik and Courtesy
- 搬运工整理之 HoloLens 开发环境搭建 01
- Javascript实现二叉搜索树
- 输入输出练习
- Date对象
- java时间格式转换
- JNDI
- class文件结构
- JAVA-JDBC: (2) 数据库的粗略的CRUD及SQL注入问题