程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> UVA - 10733 The Colored Cubes (置換)

UVA - 10733 The Colored Cubes (置換)

編輯:C++入門知識

UVA - 10733 The Colored Cubes (置換)


All 6 sides of a cube are to becoated with paint. Each side is is coated uniformly with one color. When a selectionof n different colors of paint is available, how many different cubes can youmake?

Note that any two cubes are onlyto be called "different" if it is not possible to rotate the one intosuch a position that it appears with the same coloring as the other.

Input

Each line of the input filecontains a single integer n(0denoting the number of different colors. Input is terminated by a line wherethe value of n=0. This line shouldnot be processed.

Output

For each line of input produce oneline of output. This line should contain the number of different cubes that canbe made by using the according number of colors.

SampleInput Outputfor Sample Input

1

2

0

1

10


Problem setter: EricSchmidt

Special Thanks: DerekKisman, EPS

題意:求用n中顏色塗立方體的不同種數,能旋轉到的算一種

題意:和上一題UVA - 10601 Cubes (組合+置換) 的立方體旋轉考慮的分類是一樣的,不過這裡我們考慮的是塗面的情況

1.不變置換(1)(2)(3)(4)(5)(6), 共1個;

2.沿對面中心軸旋轉 90度, 270度 (1)(2345)(6), (1)(5432)(6) 同類共 6個;

3.沿對面中心軸旋轉 180度 (1)(24)(35)(6), 同類共 3個;

4.沿對角線軸旋轉 120度, 240度 (152)(346), (251)(643) 同類共 8個;

5.沿對邊中點軸旋轉 180度 (16)(25)(43) 同類共 6個;

#include 
#include 
#include 
#include 
#include 
typedef long long ll;
using namespace std;

ll n;

ll still() {
	return n * n * n * n * n * n;
}

ll point() {
	return 4 * 2 * n * n;
}

ll edge() {
	return 6 * n * n * n;
}

ll plane() {
	return 3 * 2 * n * n * n + 3 * n * n * n * n;
}
	
ll polya() {
	ll ans = 0;
	ans += still();
	ans += point();
	ans += edge();
	ans += plane();
	return ans / 24;
}

int main() {
	while (scanf("%lld", &n) != EOF && n) {
		printf("%lld\n", polya());
	}
	return 0;
}


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved