用n种颜色给正方体着色共用多少种不同的着色方案



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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值