Zoj 2027 Travelling deformation, zoj2027

Source: Internet
Author: User

Zoj 2027 Travelling deformation, zoj2027

All 6 sides of a cube are to becoated with paint. Each side 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 before such a position that it appears with the same coloring as the other.

 

Input

Each line of the input filecontains a single integerN (0 <n <1000)Denoting the number of different colors. Input is terminated by a line wherethe valueN = 0. This line shouldnot be processed.

 

Output

For each line of input produce oneline of output. This line shoshould 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

Calculate the number of different types of cubes that can be colored with n.

The classification is the same as that in the previous question about the rotation of a cube with a combination of 10601 Cubes (combination + replacement), but here we consider the situation of surface painting.

1. Constant replacement (1) (2) (3) (4) (5) (6), 1 in total;

2. Rotate 90 degrees along the opposite center axis, 270 degrees (1) (2345) (6), (1) (5432) (6) 6 similar;

3. Rotate 180 degrees (1) (24) (35) (6) along the center axis of the opposite side. There are 3 similar items;

4. Rotate 120 degrees along the diagonal axis, 240 degrees (152) (346), (251) (643) a total of 8 similar;

5. Rotate 180 degrees (16) (25) (43) of the same type along the midpoint axis of the edge;

[Cpp]View plaincopy
  1. # Include <iostream>
  2. # Include <cstdio>
  3. # Include <cstring>
  4. # Include <cmath>
  5. # Include <algorithm>
  6. Typedef long ll;
  7. Using namespace std;
  8. Ll n;
  9. Ll still (){
  10. Return n * n;
  11. }
  12. Ll point (){
  13. Return 4*2 * n;
  14. }
  15. Ll edge (){
  16. Return 6 * n;
  17. }
  18. Ll plane (){
  19. Return 3*2 * n + 3 * n;
  20. }
  21. Ll polya (){
  22. Ll ans = 0;
  23. Ans + = still ();
  24. Ans + = point ();
  25. Ans + = edge ();
  26. Ans + = plane ();
  27. Return ans/24;
  28. }
  29. Int main (){
  30. While (scanf ("% lld", & n )! = EOF & n ){
  31. Printf ("% lld \ n", polya ());
  32. }
  33. Return 0;
  34. }



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.