URAL 1932 The Secret of Identifier 题解
2014-06-07 23:04
330 查看
http://acm.timus.ru/problem.aspx?space=1&num=1932
View Code
//最终版本,我哭了 #include<cstdio> #include<cstring> typedef long long ll; const ll MAXN=66666; const ll psn=15; const ll ps[psn]= {0x000f,0x00f0,0x00ff,0x0f00,0x0f0f,0x0ff0,0x0fff,0xf000, 0xf00f,0xf0f0,0xf0ff,0xff00,0xff0f,0xfff0,0xffff}; const ll pa[psn]= {1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; ll t[MAXN],a[MAXN],ans[5]; ll C(ll a,ll b){ ll re=1; for(ll i=0;i<b;i++){ re=re*(a-i)/(i+1); } return re; } int main() { int i,j,n; while(scanf("%d",&n)!=EOF) { memset(ans,0,sizeof(ans)); for(i=0; i<n; i++) scanf("%x",&a[i]); for(i=0; i<psn; i++) { memset(t,0,sizeof(t)); for(j=0; j<n; j++) t[a[j]&ps[i]]++; for(j=0; j<=0xffff; j++) ans[pa[i]]+=t[j]*(t[j]-1)/2; } for(i=3; i>0; i--) for(j=1;j<i;j++) ans[j]-=C(i,j)*ans[i]; ans[0]=C(n,2)-ans[1]-ans[2]-ans[3]; printf("%I64d %I64d %I64d %I64d\n",ans[3],ans[2],ans[1],ans[0]); } return 0; }
View Code
相关文章推荐
- URAL_1932_The Secret of Identifier(状态压缩+容斥)
- URAL 1932 The Secret of Identifier(容斥)
- ural 1932 The Secret of Identifier 容斥
- ural 1932 The Secret of Identifier 容斥
- ural 1932 The Secret of Identifier (容斥原理)
- ural 1932 The Secret of Identifier (容斥原理)
- the secret of sagecrm urls
- Secret of the JavaScript Ninja 学习笔记 - 1
- This application's application-identifier entitlement does not match that of the installed applicati
- Ural 1774 Barber of the Army of Mages 最大流
- URAL - 1788 On the Benefits of Umbrellas(水题)
- 《白日梦想家》The Secret Life of Walter Mitty :感谢一场白日梦
- URAL - 1920 Titan Ruins: the Infinite Power of Magic(乱搞)
- The Singular Secret of the Rockstar Programmer[成为编程巨星的唯一秘诀]
- 二分图最大匹配(匈牙利算法) URAL 1721 Two Sides of the Same Coin
- The Secret of Strand Hill (Episode 113)
- The secret of ROWID
- The Secret of String Formating
- Fast ways in R to get the first row of a data frame grouped by an identifier
- iOS-This application’s application-identifier entitlement does not match that of the installed appli