zoj 2027 Travelling Fee (最短路變形),zoj2027

來源:互聯網
上載者:User

zoj 2027 Travelling Fee (最短路變形),zoj2027

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(0<n<1000)denoting the number of different colors. Input is terminated by a line wherethe value ofn=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個;

[cpp] view plaincopy
  1. #include <iostream>  
  2. #include <cstdio>  
  3. #include <cstring>  
  4. #include <cmath>  
  5. #include <algorithm>  
  6. typedef long long ll;  
  7. using namespace std;  
  8.   
  9. ll n;  
  10.   
  11. ll still() {  
  12.     return n * n * n * n * n * n;  
  13. }  
  14.   
  15. ll point() {  
  16.     return 4 * 2 * n * n;  
  17. }  
  18.   
  19. ll edge() {  
  20.     return 6 * n * n * n;  
  21. }  
  22.   
  23. ll plane() {  
  24.     return 3 * 2 * n * n * n + 3 * n * n * n * n;  
  25. }  
  26.       
  27. ll polya() {  
  28.     ll ans = 0;  
  29.     ans += still();  
  30.     ans += point();  
  31.     ans += edge();  
  32.     ans += plane();  
  33.     return ans / 24;  
  34. }  
  35.   
  36. int main() {  
  37.     while (scanf("%lld", &n) != EOF && n) {  
  38.         printf("%lld\n", polya());  
  39.     }  
  40.     return 0;  
  41. }  



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.