2014
11-05

# DIY Cube

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.

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)

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)

3
1
2
112

Case 1: 1
Case 2: 23
Case 3: 031651434916928

import java.util.*;
import java.math.BigInteger;
public class Main {
/*
public static BigInteger pow(int x){
BigInteger a;
a=a.pow(12)
}*/
public static void main(String[] args){
int numcase;
Scanner cin = new Scanner(System.in);
numcase = cin.nextInt();
for(int i = 1;i <= numcase;++i){
BigInteger color,pow8,pow4,pow2;
color = cin.nextBigInteger();
pow8 = color.pow(8);
//System.out.println(pow8);
pow4 = color.pow(4);
BigInteger x = new BigInteger("17");
pow4 = pow4.multiply(x);
BigInteger y = new BigInteger("6");
pow2 = color.pow(2);
pow2 = pow2.multiply(y);
BigInteger sum = new BigInteger("0");
BigInteger z = new BigInteger("24");
sum = sum.divide(z);
//	System.out.println("sum = "+sum);
BigInteger p = new BigInteger("10");
p = p.pow(15);
System.out.print("Case "+i+": ");
if(sum.compareTo(p) < 0){
System.out.println(sum);
}
else{
BigInteger q = sum.mod(p);
String ss = q.toString();
int len = ss.length();
if(len < 15){
int xx = 15 - len;
for(int j = 0; j < xx; ++j)
System.out.print(0);
}
System.out.println(q);
}
}
}
}

1. 有两个重复的话结果是正确的，但解法不够严谨，后面重复的覆盖掉前面的，由于题目数据限制也比较严，所以能提交通过。已更新算法

2. /*
* =====================================================================================
*
* Filename: 1366.cc
*
* Description:
*
* Version: 1.0
* Created: 2014年01月06日 14时52分14秒
* Revision: none
* Compiler: gcc
*
* Author: Wenxian Ni (Hello World~), [email protected]
* Organization: AMS/ICT
*
* =====================================================================================
*/

#include
#include

using namespace std;

int main()
{
stack st;
int n,i,j;
int test;
int a[100001];
int b[100001];
while(cin>>n)
{
for(i=1;i>a[i];
for(i=1;i>b[i];
//st.clear();
while(!st.empty())
st.pop();
i = 1;
j = 1;

while(in)
break;
}
while(!st.empty()&&st.top()==b[j])
{
st.pop();
j++;
}
}
if(st.empty())
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}