DIY Cube

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)

Total Submission(s): 584    Accepted Submission(s): 284

Problem Description
Mr. D is interesting in combinatorial enumeration. Now he want to find out the number of ways on painting the vertexes of a cube. Suppose there are C different colors and two paintings are considered the same if they can transform from one to another by rotation.
 
Input
There are multiple test cases in the input, the first line of input contains an integer denoting the number of test cases.

For each test case, there are only one integer C, denoting the number of colors. (1 <= C <= 1000000000)
 
Output
For each test case, output the the number of painting ways. And if the number is equal or larger than 1015, output the last 15 digits.
 
Sample Input
3
1
2
112
 
Sample Output
Case 1: 1
Case 2: 23 Case 3: 031651434916928 /*
 * 题意:用n中颜色涂一个正方体的八个顶点,求有多少种方法。 假设得到的结果大于等于10^15,则输出后15位就可以。
思路:Ploya定理啊,是组合数学课本上的原题。相应于四种不同类型的旋转,1:不动,即恒等旋转有1个;2:绕三对对立面的中心旋转,有旋转90度,旋转180度,旋转270度,分别有3个;3:绕对边终点连线旋转,有6个。4:绕对角点旋转,有旋转120度和旋转240度,分别有4个。因此共同拥有24个对称。最后能够转化成公式(k^8 + 17*k^4 + 6 * k^2)/ 24 。
因为涉及到了大数,所以这道题我使用java写的,刚学java。 看着大神的分析,写了写试试。java单词好多。
 */
import java.util.*;
import java.math.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args){
int i,j;
BigInteger sum,k,temp;
temp= new BigInteger ("1000000000000000");
Scanner in=new Scanner(System.in);
int t=in.nextInt();
for(i=1;i<=t;i++){
sum= BigInteger.ZERO;
k=in.nextBigInteger();
sum=sum.add(k.pow(8));
sum=sum.add(k.pow(4).multiply(BigInteger.valueOf(17)));
sum=sum.add(k.pow(2).multiply(BigInteger.valueOf(6)));
sum=sum.divide(BigInteger.valueOf(24));
System.out.print("Case "+i+": ");
if(sum.compareTo(temp) > 0){
sum= sum.mod(temp);
for(j=sum.toString().length(); j<15;j++){
System.out.print(0);
}
}
System.out.println(sum);
}
}
}

hdu 3547 DIY Cube (Ploya定理)的更多相关文章

  1. HDOJ 3547 DIY Cube 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3547 题目大意:求用$C$种颜色给立方体的8个顶点染色的本质不同的方法.两种方法本质不同即不能通过旋转 ...

  2. hdu 3547 (polya定理 + 小高精)

    DIY CubeTime Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Sub ...

  3. poj1286Necklace of Beads(ploya定理)

    链接 这个东东是新知识 let's 从头学起吧 这篇文库讲的不错 至少把各种概念学了一遍 然后再看此题 共有两种类型的置换 一种是旋转之后相同算一种 一种是翻转之后相同算一种 对于旋转 共有N次置换 ...

  4. Ploya定理学习笔记

    由于自己的作息极其不规律导致比赛被打爆了 但是有的时候状态其实还行. 关于Ploya定理其实特别有意思 这里粘一个[dalao的blog](https://blog.csdn.net/lyc16355 ...

  5. hdu 4651 Partition (利用五边形定理求解切割数)

    下面内容摘自维基百科: 五边形数定理[编辑] 五边形数定理是一个由欧拉发现的数学定理,描写叙述欧拉函数展开式的特性[1] [2].欧拉函数的展开式例如以下: 亦即 欧拉函数展开后,有些次方项被消去,仅 ...

  6. HDU 5292 Pocket Cube 结论题

    Pocket Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5292 Description Pocket Cube is the 2×2× ...

  7. hdu 4704(费马小定理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4704 思路:一道整数划分题目,不难推出公式:2^(n-1),根据费马小定理:(2,MOD)互质,则2^ ...

  8. hdu 3037 Saving Beans Lucas定理

    Saving Beans Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. hdu 4651 - Partition(五边形数定理)

    定理详见维基百科....http://zh.wikipedia.org/wiki/%E4%BA%94%E9%82%8A%E5%BD%A2%E6%95%B8%E5%AE%9A%E7%90%86 代码如下 ...

随机推荐

  1. ajax请求携带 cookie

    之前都有这样一个理解:ajax请求时是不会自动带上cookie的,要是想让他带上的话,必须哟啊设置withCredential为true.这个说法会让人产生完全扭曲的误解,我就是其中之一.完整的无歧义 ...

  2. tf.slice()解释

    转载:https://www.jianshu.com/p/71e6ef6c121b def slice(input_, begin, size, name=None): 其中“input_”是你输入的 ...

  3. vue-router query和params传参(接收参数)$router $route的区别

    今天做项目时踩到了vue-router传参的坑(query和params),所以决定总结一下二者的区别. 直接总结干货!!! 1.query方式传参和接收参数 传参: this.$router.pus ...

  4. HTML一些标记

    4)a标签也可以转换样式为按钮 <a class="btn btn-primary" href="#" role="button"&g ...

  5. 紫书 习题 8-21 UVa 1621 (问题分析方法)

    知道是构造法但是想了挺久没有什么思路. 然后去找博客竟然只有一篇!!https://blog.csdn.net/no_name233/article/details/51909300 然后博客里面又说 ...

  6. Hive中建表注释为乱码的解决方式

    Hive中建表注释为乱码的解决方式 可以查看http://www.cnblogs.com/stono/p/7813711.html进行手动修改: 如果要解决,在Ambari配置界面中,选择Hive,输 ...

  7. [Javascript] String Padding in Javascript using padStart and padEnd functions

    ES2017 added two new string functions. They are padStart and padEndfunctions. In this lesson, we wil ...

  8. php函数in_array奇怪现象

    $k = 0; $fieldArr = array('tt', 'bb'); if ( in_array( $k, $fieldArr)) { echo '1'; } 按理来说,是不会输出1的,可是最 ...

  9. taglist安装

    注意:taglist依赖于ctags,所以要先装ctags,否则taglist装了也没法用!1.首先安装ctags1)ubuntu安装sudo apt-get install exuberant-ct ...

  10. 网络通信-ping命令