burnside
论文:http://baxterweb.com/puzzles/burnside5.pdf
n种颜色,染魔方,方案数为ans%1e9。
ans=(n^6+3*k^4+12*k^3+8*k^4)/24;
1 #include<cstdio> 2 #define ll long long 3 const ll mod=1e9+7; 4 ll pow_(ll a,ll b,ll mod) 5 { 6 ll ans=1,temp=a%mod; 7 while(b) 8 { 9 if(b&1) ans=ans*temp%mod; 10 b>>=1; 11 temp=temp*temp%mod; 12 } 13 return ans%mod; 14 } 15 ll inv(ll a,ll mod) 16 { 17 return pow_(a,mod-2,mod); 18 } 19 ll ans; 20 int main() 21 { 22 int t; 23 ll n; 24 scanf("%d",&t); 25 while(t--) 26 { 27 ans=0; 28 scanf("%lld",&n); 29 ans=(ans+pow_(n,6,mod))%mod; 30 ans=(ans+pow_(n,4,mod)*3%mod)%mod; 31 ans=(ans+pow_(n,3,mod)*12%mod)%mod; 32 ans=(ans+pow_(n,2,mod)*8%mod)%mod; 33 printf("%lld\n",ans*inv(24,mod)%mod); 34 } 35 }