Codeforces 811 A. Vladik and Courtesy
2 seconds
256 megabytes
standard input
standard 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.
Single line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of Vladik and Valera candies respectively.
Pring a single line "Vladik’’ in case, if Vladik first who can’t give right amount of candy, or "Valera’’ otherwise.
1 1
Valera
7 6
Vladik
Illustration for first test case:
Illustration for second test case:
题意就是两个人依次拿出多于上一个人的糖。
代码1:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
int num1,num2;
while(~scanf("%d%d",&n,&m)){
num1=;num2=;
int t=n;
for(int i=;i<=t;i=i+){
if(n>=i+){
num1++;
n=n-(i+);
}
if(m>=i+){
num2++;
m=m-(+i);
}
}
//cout<<num1<<" "<<num2<<endl;
if(num1<=num2) printf("Vladik\n");
else printf("Valera\n");
}
return ;
}
代码2:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
int num1,num2;
while(~scanf("%d%d",&n,&m)){
num1=;num2=;
int t=n;
for(int i=;i<=t;i++){ //我一开始写的i=0;i<=n,n会变的。
if(n>=*i-){
num1++;
n-=*i-;
}
if(m>=*i){
num2++;
m-=*i;
}
}
if(num1<=num2) printf("Vladik\n");
else printf("Valera\n");
}
return ;
}
Codeforces 811 A. Vladik and Courtesy的更多相关文章
- codeforces 811 D. Vladik and Favorite Game(bfs水题)
题目链接:http://codeforces.com/contest/811/problem/D 题意:现在给你一个n*m大小的图,你输出一个方向之后,系统反馈给你一个坐标,表示走完这步之后到的位子, ...
- codeforces 811 E. Vladik and Entertaining Flags(线段树+并查集)
题目链接:http://codeforces.com/contest/811/problem/E 题意:给定一个行数为10 列数10w的矩阵,每个方块是一个整数, 给定l和r 求范围内的联通块数量 所 ...
- codeforces 811 C. Vladik and Memorable Trip(dp)
题目链接:http://codeforces.com/contest/811/problem/C 题意:给你n个数,现在让你选一些区间出来,对于每个区间中的每一种数,全部都要出现在这个区间. 每个区间 ...
- Codeforces 811 C. Vladik and Memorable Trip
C. Vladik and Memorable Trip time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- Codeforces 811 B. Vladik and Complicated Book
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes i ...
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy【思维/模拟】
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【35.02%】【codeforces 734A】Vladik and flights
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 743E】Vladik and cards
[题目链接]:http://codeforces.com/problemset/problem/743/E [题意] 给你n个数字; 这些数字都是1到8范围内的整数; 然后让你从中选出一个最长的子列; ...
- 【44.64%】【codeforces 743C】Vladik and fractions
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- 【bzoj4817】[Sdoi2017]树点涂色 LCT+LCA+线段树
题目描述 给出一棵n个点,以1为根的有根树,每个点初始染有互不相同的颜色.定义一条路径的权值为路径上的颜色种类数.现有m次操作,每次操作为以下三种之一: 1 x: 把点x到根节点的路径上所有的点染上一 ...
- 【bzoj1458】士兵占领 有上下界最小流
题目描述 有一个M * N的棋盘,有的格子是障碍.现在你要选择一些格子来放置一些士兵,一个格子里最多可以放置一个士兵,障碍格里不能放置士兵.我们称这些士兵占领了整个棋盘当满足第i行至少放置了Li个士兵 ...
- combobox下拉框
----------------------------------------------combobox下拉框----------------------------------------- f ...
- GROUP_CONCAT(expr)
This function returns a string result with the concatenated non-NULL values from a group. It returns ...
- SICAU-OJ: 第k小
第k小 题意: 给出一个长度不超过5000的字符串,然后让你找出第K小的字串(1<=K<=5).重复的串大小相等. 题解: 这里我们知道某些串的前缀是肯定小于等于其本身的. 那么长度为5的 ...
- auto login vpnclient bat
@echo offstart "" /b "C:\Program Files (x86)\Cisco Systems\VPN Client\vpngui.exe" ...
- ubuntu安装GraphicsMagick
一. sudo apt-get install graphicsmagick 二. http://www.cnblogs.com/cocowool/archive/2010/08/16/1800954 ...
- 【Python实例二】BeautifulSoup爬虫简单实践
前言 前面安装了BeautifulSoup库,现在就来实现一下吧. 目录 一.Urllib库的使用 二.BeautifulSoup的使用 三. 一个示例 ----------------------- ...
- POJ1019 Number Sequence
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36256 Accepted: 10461 ...
- 程序员面试宝典 笔记(第六章 预处理 const 和sizeof())
void main() { "; cout<< cout<< "; cout<< cout<<strlen(ss2)<< ...