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. BZOJ 4199: [Noi2015]品酒大会 后缀自动机_逆序更新

    一道裸题,可以考虑自底向上去更新方案数与最大值. 没啥难的 细节........ Code: #include <cstdio> #include <algorithm> #i ...

  2. WordPress开启伪静态

    一.NGINX 的话在 domain.conf 的 server 增加代码: location / { try_files $uri $uri/ /index.php?$args; } 如果使用的是 ...

  3. [arc082e]ConvexScore

    题意: 给出直角坐标系中的$N$个点$(X_i,Y_i)$,定义由其中部分点构成的点集为“凸点集”当且仅当这些点恰好能构成一个凸多边形(内部没有其他点). 如图,点集$\{A,C,E\}$和$\{B, ...

  4. Docker学习总结(9)——Docker常用命令

    容器生命周期管理 - docker [run|start|stop|restart|kill|rm|pause|unpause] 容器操作运维 - docker [ps|inspect|top|att ...

  5. c++_benchMark_vector_list_deque

    title: c++_benchMark_vector_list_deque date: 2015-08-01 22:32:39 作者:titer1 + ZhangYu 出处:www.drysalte ...

  6. 2015年开源项目荣登GitHub十强榜单

    翻译出自:51CTO.com 开源是一个好东西,2015最振奋人心的就是swift开源. <软件开发时代>杂志(SD Times)回想了GitHub上的一些流行项目,这些项目已给开放和自由 ...

  7. Android 主界面长按创建快捷方式

    Android中创建快捷方式主要有两种方式.一是在代码中直接加入生成桌面快捷方式的代码:二是通过小部件加入; 这篇文章主要讲另外一种方法! 1.通过在AndroidManifest文件里为Activi ...

  8. 腾讯之困,QQ与微信各有各的烦恼

    QQ渐渐在腾讯内部弱化 在PC时代,QQ是即时通讯领域当之无愧的王者.但在微信崛起后,手机QQ未来会被微信替代的判断喧嚣至上. 早在2012年就有传言腾讯在游戏领域開始去"娱乐化" ...

  9. Could not load the FreeMarker template named &#39;select&#39;

    眼下项目使用struts2, 所以页面中就使用到了struts2的标签,可是今天在做新的功能的时候突然出现 "Could not load the FreeMarker template n ...

  10. MyEclipse常见错误汇总,中英注释版(长期更新)

    No.1 当一条语句漏写分号时错误描述如下 Syntax error, insert ";" to complete Statement(语法错误:插入分号完成语句描述) No.2 ...