用n种颜色给正方体着色共用多少种不同的着色方案
来源:互联网 发布:linux有什么认证 编辑:程序博客网 时间:2024/05/29 10:38
http://exam.upc.edu.cn/problem.php?id=4200
题目大意:
用n种颜色给正方体着色共用多少种不同的着色方案
分析:
根据Polya定理可求得(并不会推只知道公式学会了再来解释)
res=(n^6 + 3*n^4 + 12*n^3 + 8*n^2)/24
AC代码:
#include <stdio.h>#include <math.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <iostream> #include <algorithm> #include <string>#include <queue> #include <stack> #include <vector>#include <set> #include <list> #include <map>#define mset(a,i) memset(a,i,sizeof(a))#define SS(s) scanf("%s",s)#define S1(n) scanf("%d",&n)#define S2(n,m) scanf("%d%d",&n,&m)#define P(n) printf("%d\n",n)#define FIN freopen("input.txt","r",stdin)#define FOUT freopen("output.txt","w",stdout)#define gcd(a,b) __gcd(a,b)using namespace std;typedef long long ll;const double eps=1e-6;const int INF=0x3f3f3f3f;const int mod=1e9+7;const int MAX=1e6+5;const double PI=acos(-1);int dir[5][2]={0,1,0,-1,1,0,-1,0};ll qpow(ll n,ll m){n%=mod;ll ans=1;while(m){if(m%2) ans=(ans*n)%mod;m/=2;n=(n*n)%mod;}return ans;}ll inv(ll b){return b==1?1:(mod-mod/b)*inv(mod%b)%mod;}ll inv2(ll b){return qpow(b,mod-2);}int main(){int n;ll ans1;while (scanf ("%d",&n)!=EOF){ans1=0;ans1=((((qpow(n,6)%mod+3*qpow(n,4)%mod)%mod+12*qpow(n,3)%mod)%mod+8*qpow(n,2)%mod)%mod*inv(24))%mod;printf ("%lld\n",ans1);}return 0;}
阅读全文
0 0
- 用n种颜色给正方体着色共用多少种不同的着色方案
- 图的m种着色方案
- 使用至多4种颜色给多区域着色问题
- 对给定的区域图找出所有可能的不超过四种颜色的着色方案
- 给图的顶点着色
- 着色
- 着色
- 大疆笔试题目:长度为n的方格,刷3种颜色,相邻方格颜色不同,首尾颜色不同,共多少种涂色方式
- Drawable 着色的后向兼容方案
- 关于图的N可着色问题
- 导出VC6着色方案
- 【SCOI2008】【数论】着色方案
- BZOJ [SCOI2008]着色方案
- 1079: [SCOI2008]着色方案
- [bzoj1079][SCOI2008]着色方案
- BZOJ1079: [SCOI2008]着色方案
- 1079: [SCOI2008]着色方案
- 1079: [SCOI2008]着色方案
- 【NOIP2013提高组】花匠
- asp.net中web.config配置错误页
- #Git原理的简单理解
- centos7安装rabbitmq
- python的另外一个数据可视化包 seaborn
- 用n种颜色给正方体着色共用多少种不同的着色方案
- 图像处理;C++求已知两直线方程交点
- opencv 膨胀和腐蚀
- android dagger2使用全解
- 浅谈mysql的锁和索引之间莫大的联系
- 服务器IMM2实战介绍
- centos设置Apache开机启动
- 数组去重
- android 解决滑动冲突的外部拦截法