codeforces 519C C. A and B and Team Training(枚举)
2015-08-19 11:39
302 查看
题目链接:
codeforces 519C题目大意:
给出两种人的数目n和m,有两种组合方式,第一种2:1,第二种是1:2,问只用这两种组合方式得到最多的组合数。题目分析:
枚举其中一种组合方式的数量,然后算出另一种组合方式的数量。AC代码:
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std; int n,m; const int MAX = 5*1e5; int main ( ) { while ( ~scanf ( "%d%d" , &n , &m ) ) { int ans = 0; for ( int i = 0 ; i <= MAX ; i++ ) { if( 2*i > n ) break; if ( i > m ) break; int x = n -2*i; int y = m - i; ans = max ( ans , i+min(x,y/2)); } printf ( "%d\n" , ans ); } }
相关文章推荐
- 2015 HUAS Summer Trainning #6~O
- HDU 1302 The Snail
- 出现( linker command failed with exit code 1)错误总结
- 如何搞定foxmail下的.eml文件导入到win7内的outlook2007
- jboss eap 6.3 域(Domain)模式配置
- XML 包含函数fn:contains(string1,string2)的用法
- 华为OJ(Redraiment的走法)
- 【android学习笔记】理解android.intent.action.MAIN 与 android.intent.category.LAUNCHER
- 2015 Multi-University Training Contest 9-1007 Travelling Salesman Problem
- Communications link failure Last packet sent to the server was 0 ms ago.问题解决
- HDU 5402 Travelling Salesman Problem (2015 Multi-University Training Contest 9 2015多校联合)
- Aisen新浪微博客户端项目源码
- tools:context=".MainActivity的作用
- HDU 5405 Sometimes Naive 2015多校联合训练赛#9 LCT 树链剖分
- 马尔可夫链及吉布斯抽样 入门详解(Markov Chain Monte Carlo and Gibbs Sampling)
- 再谈应用环境下的TIME_WAIT和CLOSE_WAIT
- 2015 HUAS Summer Trainning #6~I
- Contain Duplicate III*******
- Contain Duplicate II
- offsetof 和 container_of