【HDU】3547 DIY Cube

题意:用k种颜色对立方体着色,旋转后相同视为相同的方案,求着色方案数。

六个面,每个面为底可以有4个旋转,总共24种置换。

初始时对下底面旋转有:x^8 + x^2 + x^4 + x^2

将垂直于水平面的四个面翻转90度到底面,并有四个旋转:4*(x^2 + x^4 + x^4 + x^4)。

将上底面旋转180度到下底面,并有四个旋转:x^4 + x^4 + x^4 + x^4。

 1 import java.util.*;
 2 import java.math.*;
 3 
 4 public class Main {
 5     public static void main(String[] args) {
 6         Scanner in = new Scanner(System.in);
 7         BigInteger x, ans, tmp;
 8         int i, j, T;
 9         tmp = new BigInteger("1000000000000000");
10         T = in.nextInt();
11         for (i = 1; i <= T; i++) {
12             x = in.nextBigInteger();
13             ans = BigInteger.ZERO;
14             ans = ans.add(x.pow(8));
15             ans = ans.add(x.pow(4).multiply(BigInteger.valueOf(17)));
16             ans = ans.add(x.pow(2).multiply(BigInteger.valueOf(6)));
17             ans = ans.divide(BigInteger.valueOf(24));
18             System.out.print("Case " + i + ": ");
19             if (ans.compareTo(tmp) > 0) {
20                 ans = ans.mod(tmp);
21                 for (j = ans.toString().length(); j < 15; j++)
22                     System.out.print(0);
23             }
24             System.out.println(ans);
25         }
26     }
27 }
原文地址:https://www.cnblogs.com/DrunBee/p/2682691.html