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. No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'

    控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...

  2. 【模板】扩展中国剩余定理(EXCRT)

    扩展中国剩余定理,是求解形如:$x\equiv a_{1}($ mod $b_{1})$$x\equiv a_{2}($ mod $b_{2})$$x\equiv a_{3}($ mod $b_{3} ...

  3. 用TamperMonkey去掉cdsn中的广告

    最近CSDN需要登录后才能查看更多内容,有点影响心情 解决方案 添加一段书签 javascript:(function(){document.getElementById('article_conte ...

  4. element-ui的table表格控件表头与内容列不对齐问题

    原文链接:点我 element-ui的table表格控件表头与内容列不对齐问题 解决方法:将以下样式代码添加到index.html.或app.vue中(必须是入口文件,起全局作用!)body .el- ...

  5. Chrome扩展程序推荐

    Chrome扩展程序 AdBlock 印象笔记 网页截图:注释&录屏 油猴 zenmate-vpn sourcegraph 推荐网站

  6. malloc 和free例程

    #include <stdio.h>#include <stdlib.h>int main(){int a;scanf("%d",&a);int * ...

  7. hdu 1978 记忆化搜索

    注意: dp[i][j] 表示(i,j)这个点有多少种方式       mark[i][j]表示这个点是否走过  假设有直接返回dp[i][j]    dp的求法为全部梦走到点的dp的和 注意mark ...

  8. hdu 1075 What Are You Talking About(map)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  9. 实习第四天(bboss框架学习)

    现在好像比较使用的管理工具是gradle管理工具,学长说这个管理工具比maven管理工具要好用! 我今天主要就是想要安装好的gradle这个管理工具,但是可能是我的eclispe版本的问题,我没能安装 ...

  10. PHP join() 函数

    PHP join() 函数 实例 把数组元素组合为一个字符串: <?php $arr = array('Hello','World!','I','love','Shanghai!'); echo ...