CF A and B and Team Training (数学)
1 second
256 megabytes
standard input
standard output
A and B are preparing themselves for programming contests.
An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.
A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.
However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.
As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.
There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?
The first line contains two integers n and m (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.
Print the maximum number of teams that can be formed.
2 6
2
4 5
3 思路是使两个数在任意时刻的差都保持最小,所以每次将小的减一,大的减二,然后又重新判断大小,再次迭代,直接暴力,刚开始以为会T,没想到A了,不过估计有直接算的公式,有空研究下。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cctype>
#include <queue>
using namespace std; int main(void)
{
int min,max;
int count;
int temp; cin >> max >> min;
count = ; while()
{
if(max < min)
{
temp = max;
max = min;
min = temp;
} min -= ;
max -= ;
if(min >= && max >= )
count ++;
else
break;
}
printf("%d\n",count); return ;
}
CF A and B and Team Training (数学)的更多相关文章
- codeforces 519C.. A and B and Team Training
C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces Round #294 (Div. 2)C - A and B and Team Training 水题
C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input ...
- 294 div2 C. A and B and Team Training
C. A and B and Team Training 题目:A and B are preparing themselves for programming contests. An import ...
- Codeforces 932E Team Work 数学
Team Work 发现网上没有我这种写法.. i ^ k我们可以理解为对于每个子集我们k个for套在一起数有多少个. 那么我们问题就变成了 任意可重复位置的k个物品属于多少个子集. 然后我们枚举k个 ...
- codeforces 519C. A and B and Team Training 解题报告
题目链接:http://codeforces.com/contest/519/problem/C 题目意思:给出 n 个 experienced participants 和 m 个 newbie ...
- 快速切题CF 158B taxi 构造 && 82A double cola 数学观察 难度:0
实在太冷了今天 taxi :错误原因1 忽略了 1 1 1 1 和 1 2 1 这种情况,直接认为最多两组一车了 2 语句顺序错 double cola: 忘了减去n的序号1,即n-- B. Taxi ...
- cf519C. A and B and Team Training(找规律)
题意 $a$个学生,$b$个教练 可以两个学生和一个教练一组,也可以两个教练和一个学生一组,问最多组成多少组 Sol 发题解的目的是为了纪念一下自己的错误思路 刚开始想的是:贪心的选,让少的跟多的分在 ...
- 【Henu ACM Round#15 C】 A and B and Team Training
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举第一种方法. 剩下的全都个第二种方法. 看看能组成多少个队伍就可以了. [代码] #include <bits/stdc+ ...
- CF R639 div 2 E Quantifier Question 数学 dfs 图论
LINK:Quantifier Question 题面过长 引起不适 读题花了好长时间 对于 和 存在符合不是很熟练 导致很懵逼的做完了. 好在还算很好想.不过wa到了一个坑点上面 自闭一大晌 还以为 ...
随机推荐
- PLSQL Developer 常用设置及快捷键
1.登录后自动选中My Objects(已验证可用) 默认情况下,PLSQL Developer登录后,Brower里会选择all Objects,如果你登录的用户是DBA, 要展开tables目录, ...
- [iOS基础控件 - 6.10] Notification 通知机制
A.定义 iOS程序都有一个NSNotificationCenter的单例对象,用来负责发布不同对象之间的通知 任何对象都能够在NSNotificationCenter发布通知,发 ...
- CSS3之背景剪裁Background-clip
CSS3之背景剪裁Background-clip是CSS3中新添加的内容.这个属性还是比较简单的,主要分五个属性值:border.padding.content.no-clip和text.下面将针对这 ...
- 模板引擎doT.js介绍及如何判断对象为空、如何嵌套循环···
doT.js 灵感来源于搜寻基于 V8 和 Node.js ,强调性能,最快速最简洁的 JavaScript 模板函数 引入 javascript 文件: <script type=" ...
- 【Java】IO流简单分辨
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/5827509.html Java的IO流体系十分庞大,并且体系层次稍复杂,很容易记混或记错.在此,我把平时经常用 ...
- 算法之旅,直奔<algorithm>之十七 find_first_of
find_first_of(vs2010) 引言 这是我学习总结 <algorithm>的第十七篇,find_first_of是匹配的一个函数.<algorithm>是c++的 ...
- android ipc通信机制之二序列化接口和Binder
IPC的一些基本概念,Serializable接口,Parcelable接口,以及Binder.此核心为最后的IBookManager.java类!!! Serializable接口,Parcelab ...
- mysql5.5主从配置
mysql主从同步# 一:mysql数据库的主从 mysql数据库5.5之后的版本和5.5以前的版本数据库主从存在差异,这里是针对数据库5.5之后的配置. 1.主库编辑my.cnf(linux的my. ...
- MEF 编程指南(四):声明导入
组合部件通过 [System.ComponentModel.Composition.ImportAttribute] 特性声明导入.类似于导出,也有几种不同的方法声明导入,即通过:字段(Fields) ...
- DuiLib(三)——控件消息
上一篇讲了控件创建,这篇说说控件消息.directui的中心思想是在真实窗口之上画出所有控件,那这些控件是如何获取各自消息的? 通过第一篇的示例可以看到窗口消息的传递过程: CWindowWnd::_ ...