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. }  



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.