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 ...
随机推荐
- [洛谷P4779]【模板】单源最短路径(标准版)
题目大意:单元最短路径(卡$SPFA$) 题解:$dijkstra$($\underline{\hspace{0.5em}}\underline{\hspace{0.5em}}gnu\underlin ...
- 关于label标签的作用
label标签的定义和用法: <label> 标签为 input 元素定义标注(标记). label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label ...
- 莫比乌斯反演题表II
bzoj3994:[SDOI2015]约数个数和 **很好推+有个小结论bzoj3309:DZY Loves Math ***很好推+线筛某函数/卡常bzoj4816:[Sdoi2017]数字表格 * ...
- LaTeX的图片插入及排版[转]
LaTeX中一般只直接支持插入eps(Encapsulated PostScript)格式的图形文件, 因此在图片插入latex文档之前应先设法得到图片的eps格式的文件. UNIX下的各种应用软件都 ...
- [poj 2274]后缀数组+最长公共子串
题目链接:http://poj.org/problem?id=2774 后缀数组真的太强大了,原本dp是O(nm)的复杂度,在这里只需要O(n+m). 做法:将两个串中间夹一个未出现过的字符接起来,然 ...
- 异常message:There is no database named cloudera_manager_metastore_canary_test_db_hive_hivemetastore
NoSuchObjectException(message:There is no database named cloudera_manager_metastore_canary_test_db_h ...
- React 开发常见报错解决方法
1. 使用 redux 的异步 action 时浏览器报错: Error: Actions must be plain objects. Use custom middleware for async ...
- Java中中英文对齐输出问题,以及Java中的格式化输出
一 中英文对齐输出问题 问题,要求控制台输出如下: abcefg def 森林 阿狗 其实就是要求对齐输出,各种查找java的格式化输出,然后发现只要一个简单的“\t”就可以实现. 代码如下: Sy ...
- MyBatis的SQL语句映射文件详解
SQL 映射XML 文件是所有sql语句放置的地方.需要定义一个workspace,一般定义为对应的接口类的路径.写好SQL语句映射文件后,需要在MyBAtis配置文件mappers标签中引用 < ...
- 转: 构建基于Nginx的文件服务器思路与实现
在Web项目中使用独立的服务器来保存文件和图片的好处很多,如:便于统一管理,分流web服务器的压力,可进行访问加速等.另外当web服务器需要做集群进行负载均衡时,图片和文件上传在各个服务器之间同步将是 ...