problem 2221 Runningmanaccept:130 submit:404
Time limit:1000 mSec Memory limit:32768 KB problem Description
ZB loves watching runningman! There ' s a game in Runningman called vs 100.
There is teams, each of many people. There is 3 rounds of fighting, in each round the and the teams send some people to fight. In each round, whichever team sends more people wins, and if the both teams send the same amount of people, Runningman team Wins. Each person can is 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 is decided before the whole game starts.
We know that there is N people on the Runningman team, and that there is M people on the opposite team. Now ZB wants to know whether there exists a arrangement of people for the Runningman team so it 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 the integers n and M. (1 <= N, M <= 10^9).
Output
For each test case, the Output "Yes" if there exists a arrangement of people so and the Runningman team can always win. "No" If there isn ' t such an arrangement. (without the quotation marks.)
Sample Input2 Outputno Yes
Idea: Greed.
Because of a total of three teams, because two teams have to choose the best strategy, regardless of B team to put, to make a team win.
Set a team n people, B team m people.
Set a first row a person, if b this to win, according to the best on the faction (a+1) people, so a next two games must win can get (n-a)/2>= (m-a-1); Because team B has won once. So, you can put the rest on one team.
If b This choice loses, that he does not send a person this time, then in the next two games a must win once, then a as long as in the police station has the remainder (n-a), because there is also a no send people, so B will be in that send 1 people,
So a to win there is (N-A) >=M-1; Such two inequalities can be established at the same time (N+1>=3*M/2)
1 1 //############
22#include <stdio.h>
33#include <algorithm>
44#include <string.h>
55#include <stdlib.h>
6 6#include <math.h>
77#include <iostream>
88#include <cstdio>
99#defineSC (x) scanf ("%i64d", &x)
TenTen#definePR (x) printf ("%i64d", X)
One One#definePRR (x) printf ("%i64d", X)
A A#definePRRR (x) printf ("%i64d\n", X)
- -typedefLongLongll
- -Constll n=1e9+7;
the thell aa[5];
- -ll bb[5];
- -using namespaceSTD;
- -intMainvoid)
+ +{
- -ll I,j,k,p,q;
+ +SC (k);
A A while(k--)
at at{
- -SC (p);
- -SC (q);
- - if((p+1) <q*3/2)
- -{
- -printf"no\n");
in in}
- -Else
to to{
+ +printf"yes\n");
- -}
the the}
* *return0;
$ $}
Panax Notoginseng
-
2 ###
2#include <stdio.h>
3#include <algorithm>
4#include <string.h>
5#include <stdlib.h>
6#include <math.h>
7#include <iostream>
8#include <cstdio>
9#defineSC (x) scanf ("%i64d", &x)
Ten#definePR (x) printf ("%i64d", X)
One#definePRR (x) printf ("%i64d", X)
A#definePRRR (x) printf ("%i64d\n", X)
-typedefLongLongll
-Constll n=1e9+7;
thell aa[5];
-ll bb[5];
-usingnamespaceSTD;
-intMainvoid)
+{
-ll I,j,k,p,q;
+SC (k);
A while(k--)
at{
-SC (p);
-SC (q);
-ll mm=p/3;
-ll nn=q/2;
-aa[0]=mm;
inll ss=p-mm;
-if(ss%2==0)
to{
+aa[1]=ss/2;
-aa[2]=ss/2;
the}
*Else
${
Panax Notoginsengaa[1]=ss/2;
-aa[2]=ss/2+1;
the}
+Sort (aa,aa+3);
Aif(nn>aa[0]&&nn>aa[1])
the{
+printf"no\n");
-}
$Else
${
-printf"yes\n");
-}
the}
- return0;
Wuyi}
Problem 2221 Runningman (FUZOJ)