Home > Database > Mysql Tutorial > body text

zoj2027TravellingFee(最短路变形)

WBOY
Release: 2016-06-07 16:02:50
Original
1129 people have browsed it

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 cal

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 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个;

<strong>[cpp]</strong> view plaincopy
Copy after login
在CODE上查看代码片派生到我的代码片
  1. #include <iostream></iostream>
    Copy after login
  2. #include <cstdio></cstdio>
    Copy after login
  3. #include <cstring></cstring>
    Copy after login
  4. #include <cmath></cmath>
    Copy after login
  5. #include <algorithm></algorithm>
    Copy after login
  6. typedef long long ll;
    Copy after login
  7. using namespace std;
    Copy after login
  8. ll n;
    Copy after login
  9. ll still() {
    Copy after login
  10. return n * n * n * n * n * n;
    Copy after login
  11. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  12. ll point() {
    Copy after login
  13. return 4 * 2 * n * n;
    Copy after login
  14. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  15. ll edge() {
    Copy after login
  16. return 6 * n * n * n;
    Copy after login
  17. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  18. ll plane() {
    Copy after login
  19. return 3 * 2 * n * n * n + 3 * n * n * n * n;
    Copy after login
  20. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  21. ll polya() {
    Copy after login
  22. ll ans = 0;
    Copy after login
  23. ans += still();
    Copy after login
  24. ans += point();
    Copy after login
  25. ans += edge();
    Copy after login
  26. ans += plane();
    Copy after login
  27. return ans / 24;
    Copy after login
  28. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  29. int main() {
    Copy after login
  30. while (scanf("%lld", &n) != EOF && n) {
    Copy after login
  31. printf("%lld\n", polya());
    Copy after login
  32. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
  33. return 0;
    Copy after login
  34. }
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
    Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!