• Problem 2221 RunningMan(fuzoj)


     Problem 2221 RunningMan

    Accept: 130    Submit: 404
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

     Problem 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

    2 100 100 200 100

     Sample Output

    No Yes

     思路:贪心.

    因为总共就分三个队,因为两个队都要选取最优的策略,不论B队咋放,要使A队赢 。

    设A队N人,B队M人。 

    设A第一次排a人,如果B这次要赢,根据最优就派(a+1)人,所以A下两场必需赢就可以得到(N-a)/2>=(M-a-1);因为B队已经赢了一次所以,可以把剩下的都放在一个队上。

    假如B这次选择输,那他就在这次不派人,那么在下两场中A必须在赢一次,那么A只要在一次中派出所有剩下的人(N-a),因为还有一场A没有派人,所以B要会在那派上1人,

    所以A要赢就有(N-a)>=M-1;这样两个不等式同时成立可以得(N+1>=3*M/2) 

      1 1 //############

     2  2 #include<stdio.h>
     3  3 #include<algorithm>
     4  4 #include<string.h>
     5  5 #include<stdlib.h>
     6  6 #include<math.h>
     7  7 #include<iostream>
     8  8 #include<cstdio>
     9  9 #define sc(x) scanf("%I64d",&x)
    10 10 #define pr(x) printf("%I64d",x)
    11 11 #define prr(x) printf(" %I64d",x)
    12 12 #define prrr(x) printf("%I64d ",x)
    13 13 typedef long long ll;
    14 14 const ll N=1e9+7;
    15 15 ll aa[5];
    16 16 ll bb[5];
    17 17 using namespace std ;
    18 18 int main(void)
    19 19 {
    20 20     ll i,j,k,p,q;
    21 21     sc(k);
    22 22     while(k--)
    23 23     {
    24 24         sc(p);
    25 25         sc(q);
    26 26         if((p+1)<q*3/2)
    27 27         {
    28 28             printf("No ");
    29 29         }
    30 30         else
    31 31         {
    32 32             printf("Yes ");
    33 33         }
    34 34     }
    35 35     return 0;
    36 36 }
    37  
    38  

      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 #define sc(x) scanf("%I64d",&x)
    10 #define pr(x) printf("%I64d",x)
    11 #define prr(x) printf(" %I64d",x)
    12 #define prrr(x) printf("%I64d ",x)
    13 typedef long long ll;
    14 const ll N=1e9+7;
    15 ll aa[5];
    16 ll bb[5];
    17 using namespace std ;
    18 int main(void)
    19 {
    20     ll i,j,k,p,q;
    21     sc(k);
    22     while(k--)
    23     {
    24         sc(p);
    25         sc(q);
    26         ll mm=p/3;
    27         ll nn=q/2;
    28         aa[0]=mm;
    29         ll ss=p-mm;
    30         if(ss%2==0)
    31         {
    32             aa[1]=ss/2;
    33             aa[2]=ss/2;
    34         }
    35         else
    36         {
    37             aa[1]=ss/2;
    38             aa[2]=ss/2+1;
    39         }
    40         sort(aa,aa+3);
    41         if(nn>aa[0]&&nn>aa[1])
    42         {
    43             printf("No ");
    44         }
    45         else
    46         {
    47             printf("Yes ");
    48         }
    49     }
    50     return 0;
    51 }


    油!油!you@
  • 相关阅读:
    text-align: justify;浏览器、安卓手机不兼容问题
    sse 与 socket 摘录-推送常用技术
    mui longtap 事件无效
    对已有框架进行整理调用
    mui init 出现无法引入子页面问题
    mui页面交互
    js md5
    Ps大片教程:—失落之城
    用PS制作炫彩字教程
    如何将图片素材转为矢量图?
  • 原文地址:https://www.cnblogs.com/zzuli2sjy/p/5180243.html
Copyright © 2020-2023  润新知