2016寒假个人赛(1)J(模拟)

来源:互联网 发布:qt高级编程 源码 qt5 编辑:程序博客网 时间:2024/06/06 03:42
J - J
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit Status

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

2100 100200 100

Sample Output

NoYes

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;}


1 0
原创粉丝点击