Codeforces Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会
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 Round #416(Div. 2)-811A.。。。 811B.。。。 811C.dp。。。不会的更多相关文章
- Codeforces Round #174 (Div. 1) B. Cow Program(dp + 记忆化)
题目链接:http://codeforces.com/contest/283/problem/B 思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记 ...
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round#416 Div.2
A. Vladik and Courtesy 题面 At regular competition Vladik and Valera won a and b candies respectively. ...
- Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
http://codeforces.com/contest/811/problem/C 题意: 给出一行序列,现在要选出一些区间来(不必全部选完),但是相同的数必须出现在同一个区间中,也就是说该数要么 ...
- Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
地址:http://codeforces.com/contest/811/problem/D 题目: D. Vladik and Favorite Game time limit per test 2 ...
- Codeforces Round #416 (Div. 2) A+B
A. Vladik and Courtesy 2 seconds 256 megabytes At regular competition Vladik and Valera won a and ...
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- Codeforces Round #416 (Div. 2)A B C 水 暴力 dp
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【分类讨论】【spfa】【BFS】Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
那个人第一步肯定要么能向下走,要么能向右走.于是一定可以判断出上下是否对调,或者左右是否对调. 然后他往这个方向再走一走就能发现一定可以再往旁边走,此时就可以判断出另一个方向是否对调. 都判断出来以后 ...
随机推荐
- 贪心算法——Fence Repair(POJ 3253)
题目描述 农夫约翰为了修理栅栏,要将一块很长的木板切割成N块.准备切成的木板长度为L1,L2,L3--LN,未切割前木板的长度恰好为切割后木板长度的总和.每次切断木板时,需要的开销为这块木板的长度.请 ...
- Java并发编程之ThreadLocal源码分析
## 1 一句话概括ThreadLocal<font face="微软雅黑" size=4> 什么是ThreadLocal?顾名思义:线程本地变量,它为每个使用该对象 ...
- C#中&与&&的区别
c#&是什么意思? 看过一些文章,关于这个的简单而容易被忽略的语法,说的总有点瑕疵. 贴代码15秒之内应该能知道c#中一个&和两个&&的区别,开始计数了........ ...
- SuperSocket 最基础入门
---恢复内容开始--- SuperSocket 是什么? 首先我们明确一下SuperSocket 本质是什么? 网络框架 ! ok , 那么我们直接上上官网,作者已经开源到Github,可以做两件 ...
- UVALive 4850 Installations
题目大意:有若干个任务,每个任务耗时si,期限为di,同一时间只能做一个任务.对于一个任务,惩罚值为max(0,完成时间-期限).问怎么安排,使(最大惩罚值+次大惩罚值)最小,O(n^2). 如果没有 ...
- HTML知识点记录
1.input的type设置为file时,设置multiple属性可以同时选择多个文件.
- [数据清洗]-使用 Pandas 清洗“脏”数据
概要 准备工作 检查数据 处理缺失数据 添加默认值 删除不完整的行 删除不完整的列 规范化数据类型 必要的转换 重命名列名 保存结果 更多资源 Pandas 是 Python 中很流行的类库,使用它可 ...
- DNS 域名系统的简介
一.DNS域名系统简介 1.网络中为了区别各个主机,必须为每台主机分配一个唯一的地址, 这个地址即称为“IP 地址.但这些数字难以记忆, 所以采用“域名” 的方式来取代这些数字. 2.当某台主机要与其 ...
- UWP 使用OneDrive云存储2.x api(二)【全网首发】
接上一篇 http://www.cnblogs.com/hupo376787/p/8032146.html 上一篇提到为了给用户打造一个完全无缝衔接的最佳体验,UWP开发者最好也要实现App设置和数据 ...
- 虚拟机下linux系统安装nginx
近在windows虚机下安装nginx,也遇到部分问题,写篇随笔总结一下 一.安装虚机 windows下安装虚拟机我就不说了,一搜一大把,一直下一步就ok了 二. 打开虚拟安装nginx 1.选择版本 ...