Advertisement
Guest User

Untitled

a guest
Aug 12th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. int check(int *a)
  6. {
  7.     int c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  8.     int i;
  9.     for (i = 0; i < 10; i++) {
  10.         c[a[i]]++;
  11.         if (c[a[i]] > 2)
  12.             return 0;
  13.     }
  14.     return 1;
  15. }
  16.  
  17. int main()
  18. {
  19.     int cnt = 0;
  20.  
  21.     int a[10];
  22.  
  23.     unsigned long long res = 0;
  24.  
  25.     for (a[0] = 0; a[0] < 16; a[0]++) {
  26.     for (a[1] = a[0]; a[1] < 16; a[1]++) {
  27.     for (a[2] = a[1]; a[2] < 16; a[2]++) {
  28.     for (a[3] = a[2]; a[3] < 16; a[3]++) {
  29.     for (a[4] = a[3]; a[4] < 16; a[4]++) {
  30.     for (a[5] = a[4]; a[5] < 16; a[5]++) {
  31.     for (a[6] = a[5]; a[6] < 16; a[6]++) {
  32.     for (a[7] = a[6]; a[7] < 16; a[7]++) {
  33.     for (a[8] = a[7]; a[8] < 16; a[8]++) {
  34.     for (a[9] = a[8]; a[9] < 16; a[9]++) {
  35.         if (!check(a))
  36.             continue;
  37.  
  38.         cnt += 1;
  39.  
  40.         int numdub = 0;
  41.         for (int s = 1; s < 10; s++) {
  42.             if (a[s] == a[s-1])
  43.                 numdub++;
  44.         }
  45.  
  46.         res += 3628800 / (1 << numdub);
  47.     }}}}}}}}}}
  48.  
  49.     std::cout << cnt << std::endl;
  50.     std::cout << res << std::endl;
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement