HDU 5873 Football Games(竞赛图兰道定理)

http://acm.hdu.edu.cn/showproblem.php?pid=5873

题意:

现在有比赛,所有队伍两两进行比赛,赢的积2分,输的积0分,如果平局的话就各自都积1分,现在给出每只队伍的得分情况,判断是否合法。

思路:

竞赛图中有关于得分序列这方面的知识,这里引用一下来自http://blog.csdn.net/a_crazy_czy/article/details/73611366博主的讲解。

那么,对于这道题目来说,首先对所有得分排个序,再依次处理即可,前i只队伍的得分情况必须得大于等于$i*(i-1)$,因为每次比赛都会使得总分+2分,而当i=n时,也就是判断到最后一支队伍时,必须要等于$n*(n-1)$。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 typedef long long ll;
 6 const int maxn=20000+5;
 7
 8 int n;
 9 int a[maxn];
10
11 int main()
12 {
13     //freopen("in.txt","r",stdin);
14     int T;
15     while(~scanf("%d",&T))
16     {
17         while(T--)
18         {
19             bool flag=true;
20             scanf("%d",&n);
21             for(int i=1;i<=n;i++) scanf("%d",&a[i]);
22             sort(a+1,a+n+1);
23             int sum=0;
24             for(int i=1;i<=n;i++)
25             {
26                 sum+=a[i];
27                 if(i<n)
28                 {
29                     if(sum<i*(i-1))  {flag=false;break;}
30                 }
31                 else
32                 {
33                     if(sum!=i*(i-1))  flag=false;
34                 }
35             }
36             if(flag)  puts("T");
37             else puts("F");
38         }
39     }
40     return 0;
41 }
时间: 2024-10-13 06:35:48

HDU 5873 Football Games(竞赛图兰道定理)的相关文章

HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 802    Accepted Submission(s): 309 Problem Description A mysterious country will hold a football world championships---Abnormal Cup

HDU 5873 Football Games

随便判了几个条件就过了,也不知道对不对的. 正解应该是: $[1].$${s_1} + {s_2} + {s_3} + ...... + {s_n} = n(n - 1)$ $[2].$${s_1} + {s_2} + {s_3} + ...... + {s_i} ≥ i(i - 1)$ #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring&g

2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873

Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 439    Accepted Submission(s): 157 Problem Description A mysterious country will hold a football world championships---Abnormal Cup

HDU 4704 Sum( 费马小定理 )

HDU 4704 Sum( 费马小定理 ) 理解能力果然拙计,,题目看半天没懂什么意思. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; #define MOD 1000000007 char str[100010]; LL fast_mod( LL a, int b) { LL res = 1; while( b )

HDU 4924 Football Manager(状压DP)

题目连接 : http://acm.hdu.edu.cn/showproblem.php?pid=4924 题意 : n(<=20)个人选出11个人作为首发组成a-b-c阵容,每个人都有自己擅长的位置,并且每个人和其他人会有单向的厌恶和喜欢关系,每个人对于自己擅长的位置都有两个值CA和PA,有喜欢或者厌恶关系的两个人在一起也会影响整个首发的CA总值,要求选出一套阵容使得CA最大,或者CA一样的情况下PA最大. 思路 : 状压搞,dp[s]s的二进制表示20个人中选了那几个人,然后规定选进来的顺序

2016大连网络赛 Football Games

Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description A mysterious country will hold a football world championships---Abnormal Cup, attracting football teams and fans from all around th

HDU 4349 Xiao Ming&#39;s Hope lucas定理

Xiao Ming's Hope Time Limit:1000MS     Memory Limit:32768KB Description Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend. The day 2

hdu 4349 Xiao Ming&#39;s Hope (Lucas定理推导)

题意:求C (n,0),C (n,1),C (n,2)...C (n,n).奇数的个数 思路:我们分析C(n,m)%2,那么由Lucas定理可知,n和m可以写成二进制的形式,假设n=1001101,那么m是0~1001101,我们知道C(0,1)=0,因此如果n=1001101的0对应位置的m二进制位为1那么C(n,m) % 2==0,因此m对应n为0的位置只能填0,而1的位置填0,填1都是1(C(1,0)=C(1,1)=1),不影响结果为奇数,并且保证不会出n的范围,因此所有的情况即是n中1位

2016 ACM/ICPC Asia Regional Dalian Online 1006 Football Games

题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5873 Problem Description A mysterious country will hold a football world championships---Abnormal Cup, attracting football teams and fans from all around the world. This country is so mysterious t