2016寒假个人赛(1)J(模拟)
来源:互联网 发布:qt高级编程 源码 qt5 编辑:程序博客网 时间:2024/06/06 03:42
Description
ZB loves watching RunningMan! There's a game in RunningMan called 100 vs 100.
There are two teams, each of many people. There are 3 rounds of fighting, in each round the two teams send some people to fight. In each round, whichever team sends more people wins, and if the two teams send the same amount of people, RunningMan team wins. Each person can be sent out to only one round. The team wins 2 rounds win the whole game. Note, the arrangement of the fighter in three rounds must be decided before the whole game starts.
We know that there are N people on the RunningMan team, and that there are M people on the opposite team. Now zb wants to know whether there exists an arrangement of people for the RunningMan team so that they can always win, no matter how the opposite team arrange their people.
Input
The first line contains an integer T, meaning the number of the cases. 1 <= T <= 50.
For each test case, there's one line consists of two integers N and M. (1 <= N, M <= 10^9).
Output
For each test case, Output "Yes" if there exists an arrangement of people so that the RunningMan team can always win. "No" if there isn't such an arrangement. (Without the quotation marks.)
Sample Input
Sample Output
Hint
In the second example, the RunningMan team can arrange 60, 60, 80 people for the three rounds. No matter how the opposite team arrange their 100 people, they cannot win.
题意:
给出n,m两个数,要你去求是否存在一种无论m怎样分都小于n两次。
思路:
这题其实就是根据n要平分为三个,而m就可以不管,只是随着n的变化而变化。所以只要从n平分的三份中找出最小的然后再用比较是否小于m,小于则找到一次大于n的。
AC代码:
#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>#include<cmath>#include<ctime>#include<cstdlib>#include<queue>#include<vector>#include<set>using namespace std;const int T=1500;#define inf 0x3f3f3f3fL#define mod 1000000000typedef long long ll;typedef unsigned long long LL;int main(){#ifdef zsc freopen("input.txt","r",stdin);#endifint N,i,j,k,n,m;scanf("%d",&N);int x[5];while(N--){scanf("%d%d",&n,&m);x[0] = n/3;x[1] = (n-x[0])/2;x[2] = n-x[0]-x[1];sort(x,x+3);for(i=0,k=0;i<3;++i){if(x[i]+1<=m){k++;m -= (x[i]+1);}else{break;}}if(k<2){printf("Yes\n");}else {printf("No\n");}} return 0;}
- 2016寒假个人赛(1)J(模拟)
- CDZSC_2016寒假个人赛(2)-G(模拟)
- CDZSC_2016寒假个人赛(2)-L(模拟)
- 2016寒假个人赛(1)B(数学)
- 2016寒假个人赛(1)A(贪心)
- 2016寒假个人赛(1)C(背包)
- 模拟赛 J跳(组合数)
- HPUOJ---2017寒假作业--专题-1/J-Key Set
- CDZSC_2016寒假个人赛(2)-C
- 2016寒假训练——栈模拟
- 个人赛 J: 导弹拦截系统
- SDUT - 2017年寒假集训 阶段测试赛3(个人) -- 解题报告
- 寒假个人总结
- 寒假前刷题(1)
- J - Candy Sharing Game(模拟题)
- 【浙江理工大学2016年新生赛暨全国新生邀请赛】 J 萌新吃果果,ZSTUOJ 4286【模拟】
- Problem J. Jumbled Compass---Urozero Autumn Training Camp 2016-Day 1||签到&模拟时针转动
- 12th浙江省省赛 J Convert QWERTY to Dvorak(细节模拟题)
- Linux 中的零拷贝技术 二
- 反方向ProgressBar
- DOM元素的各种宽度和高度
- 柱状图 js工具highcharts
- Android购物车的实现(升级版 仿淘宝)
- 2016寒假个人赛(1)J(模拟)
- ubuntu利用nginx配置https服务器
- 三层登录—c#
- float--->double 的转换
- java工程引入jar包
- ImageLoader
- iOS MBProgressHUD的简单使用
- 多项选择~checkbox的简单运用
- Android 坐标系