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\n",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\n");
29 29         }
30 30         else
31 31         {
32 32             printf("Yes\n");
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\n",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\n");
44         }
45         else
46         {
47             printf("Yes\n");
48         }
49     }
50     return 0;
51 }

时间: 2024-10-22 06:58:41

Problem 2221 RunningMan(fuzoj)的相关文章

FZU Problem 2221 RunningMan

一开始就跑偏了,耽误了很长时间,我和队友都想到博弈上去了...我严重怀疑自己被前几个博弈题给洗脑了...贪心的做法其实就是我们分两种情况,因为A先出,所以B在第一组可以选择是赢或输,如果要输,那直接不上人,而A已经赢了一场,所以A只要再赢一场就可以了,A的最优策略是把自己剩下的全上去,即为(a,n-a,0)的形式,B的最优为(0,m-1,1)的形式,若A要赢就是(n-a) >= (m-1).如果B选择在第一场赢的话,那B应该在第一场放上a+1个人,A的最优为(a,(n-a)/2,(n-a)/2)

FZU 2221 RunningMan(跑男)

[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,

2015福建省赛

 Problem A Super Mobile Charger Accept: 217    Submit: 402 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description While HIT ACM Group finished their contest in Shanghai and is heading back Harbin, their train was delayed due to the hea

CSU-2221 假装是区间众数(ST表模版题)

题目链接 题目 Description 给定一个非递减数列Ai,你只需要支持一个操作:求一段区间内出现最多的数字的出现次数. Input 第一行两个整数N,Q 接下来一行有N个整数,表示这个序列. 接下来Q行每行一个操作:A B,询问A到B之间出现最多的数字. 1<=N,Q<=100000.-100000<=Ai<=100000 Output 每组数据若干行,每行对应一个询问的答案. Sample Input 10 3 -1 -1 1 1 1 1 3 10 10 10 2 3 1

RunningMan【第六届福建省大学生程序设计竞赛-重现赛】

RunningMan Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 2221 64-bit integer IO format: %I64d      Java class name: Main Prev Submit Status Statistics Discuss Next ZB loves watching RunningMan! There's a ga

A Math Problem

A Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 237    Accepted Submission(s): 117 Problem Description You are given a positive integer n, please count how many positive integers

Water Problem

water problem 发布时间: 2015年10月10日 15:34   时间限制: 1000ms   内存限制: 256M 描述 题意很简单 给你N个数, Q个查询 每次查询给你一个区间[L, R] 你要找出 [L, R] 这个区间里面取模M后的最大值. 输入 第一行一个T,表示测试数据组数.第二行两个整数N, M (1<=N<=10^5, 1<=M<=10^9).第三行给你N个整数 整数范围在1到10^9之间.第四行给你一个整数Q. ( 1<=Q<=10^5)

FOJ Problem 2261 浪里个浪

                                                                                                                                                           Problem 2261 浪里个浪 Accept: 40    Submit: 106Time Limit: 1500 mSec    Memory Limit : 32768 KB Pro

XJTUOJ wmq的A&#215;B Problem FFT

wmq的A×B Problem 发布时间: 2017年4月9日 17:06   最后更新: 2017年4月9日 17:07   时间限制: 3000ms   内存限制: 512M 描述 这是一个非常简单的问题. wmq如今开始学习乘法了!他为了训练自己的乘法计算能力,写出了n个整数,并且对每两个数a,b都求出了它们的乘积a×b.现在他想知道,在求出的n(n−1)2个乘积中,除以给定的质数m余数为k(0≤k<m)的有多少个. 输入 第一行为测试数据的组数. 对于每组测试数据,第一行为2个正整数n,