This is part of the vertex coloring of the cube, polyA counting: There is a formula to set directly, (k ^ 8 + 17 * k ^ 4 + 6 * k ^ 2)/24; k indicates the number of colors. because the question is high precision, it is obvious that Java can be used. However, nbutoj does not support direct orz... Then we started the sad reminder of WA ,,,,
import java.util.*;import java.math.*;import java.lang.*;public class Main {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stub Scanner cin=new Scanner(System.in); int t=cin.nextInt();for(int i=1;i<=t;i++) { BigDecimal a=cin.nextBigDecimal(),b=BigDecimal.valueOf(24),c,d=BigDecimal.valueOf(17); c=(a.pow(8).add(d.multiply(a.pow(4))).add(BigDecimal.valueOf(6).multiply(a.pow(2)))).divide(b); String str=c.toPlainString(); // System.out.println("C==="+c+" "+"str=="+str); System.out.print("Case "+i+": "); if(str.length()>15) { for(int j=str.length()-15;j<str.length();j++) { System.out.print(str.charAt(j)); } System.out.println(); }else{ System.out.println(str); } }}}