UVA
来源:互联网 发布:java数组声明 编辑:程序博客网 时间:2024/06/15 20:38
就和普通的母函数差不多。。展开。。组合数求一下。。恩
#include<iostream>#include<cstdio>#include<math.h>#include<algorithm>#include<map>#include<set>#include<bitset>#include<stack>#include<queue>#include<string.h>#include<string>#include<cstring>#include<vector>#include<time.h>#include<stdlib.h>using namespace std;#define INF 0x3f3f3f3f#define INFLL 0x3f3f3f3f3f3f3f3f#define FIN freopen("input.txt","r",stdin)#define mem(x,y) memset(x,y,sizeof(x))typedef unsigned long long ULL;typedef long long LL;#define fuck(x) cout<<x<<endl;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef pair<pair<int,int>,int> PIII;typedef pair<int,int> PII;const double eps=1e-5;const int P=1e9+7;const int MX=1e2+5;int n,m;LL C[41][41];struct Polya{ int n,sz,m;//置换群阶的大小sz,颜色总数m int cnt[3],tmp[3]; void init(int nn,int SZ,int M) { sz=SZ,m=M,n=nn; mem(cnt,0); } //循环长度为k LL solve(int k) { int t=0; LL sum=1; for(int i=0; i<m; i++) if(tmp[i]%k==0) { tmp[i]/=k; t+=tmp[i]; } else return 0; //总共n组,然后通过组合数确定方案数 for(int i=0; i<m; i++) { sum*=C[t][tmp[i]]; t-=tmp[i]; } return sum; } //不动,二维旋转 LL solve1() { //静止不到,不需要有边相同 LL ans=0; for(int i=0; i<n; i++) { memcpy(tmp,cnt,sizeof(cnt)); ans+=solve(n/__gcd(i,n)); } //cout<<ans<<endl; return ans; } //线线 LL solve3() { LL ans=0; memcpy(tmp,cnt,sizeof(cnt)); return n/2*solve(2); } //点点 LL solve4() { //有4组顶点,每个轴可以转120以及160度 //每组旋转,循环节长度为3,3条边的颜色一样 LL ans=0; for(int i=0; i<m; i++) for(int j=0; j<m; j++) { memcpy(tmp,cnt,sizeof(cnt)); tmp[i]--,tmp[j]--; ans+=solve(2); } return n/2*ans; } LL solve6() { LL ans=0; for(int i=0; i<m; i++) { memcpy(tmp,cnt,sizeof(cnt)); tmp[i]--; ans+=solve(2); } return n*ans; } LL cal() { LL ans=0; ans+=solve1();//不动,二维旋转 //ans+=solve2();//面面 if(n&1)ans+=solve6();//点线 else { ans+=solve3();//线线 ans+=solve4();//点点 //ans+=solve5();//点面 } //ans+=solve7();//面线 return ans/sz;// }} pp;int main(){ for(int i=0; i<=40; i++) C[i][0]=C[i][i]=1; for(int i=1; i<=40; i++) for(int j=1; j<i; j++) C[i][j]=C[i-1][j-1]+C[i-1][j]; int T; cin>>T; while(T--) { int a,b,c; scanf("%d%d%d",&a,&b,&c); pp.init(a+b+c,(a+b+c)*2,3); pp.cnt[0]=a; pp.cnt[1]=b; pp.cnt[2]=c; cout<<pp.cal()<<endl; } return 0;}
阅读全文
0 0
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- 【CodeForces】710C
- 解决MATLAB2016a不能设置为.m文件默认打开方式
- EasyDSS高性能流媒体服务器前端重构(四): webpack + video.js 打造流媒体服务器前端
- HTTP cookies 详解
- javascript apply()使用详解
- UVA
- javaWeb中页面设计小结
- 游戏架构设计的一些整理
- zepto 源码阅读记录
- 虚拟机:系统与进程的通用平台.pdf
- 从零到一学Mycat:入门及配置文件详解
- java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection
- Git 配置 ssh 公钥
- 系统烧写步骤