fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. char s[11];
  5.  
  6. int cmp(char *a, char *b) {
  7. int x = 0, y = 0;
  8. for (int i=0; i<5; ++i) {
  9. if (a[i] == b[i]) { ++x; continue; }
  10. for (int j=0; j<5; ++j) if (a[i] == b[j]) { ++y; break; }
  11. }
  12. return 10 * x + y;
  13. }
  14.  
  15.  
  16. char match[8];
  17.  
  18. int main() {
  19. sprintf(s, "0123456789");
  20. do {
  21. reverse(s+5, s+10);
  22.  
  23. int cnt = 0;
  24. match[0] = (cmp(s, "76070") == 2 ? '1' : '0'); if (match[0] == '1') ++cnt;
  25. match[1] = (cmp(s, "24112") == 10 ? '1' : '0'); if (match[1] == '1') ++cnt;
  26. match[2] = (cmp(s, "93535") == 11 ? '1' : '0'); if (match[2] == '1') ++cnt;
  27. match[3] = (cmp(s, "67253") == 2 ? '1' : '0'); if (match[3] == '1') ++cnt;
  28. match[4] = (cmp(s, "01497") == 12 ? '1' : '0'); if (match[4] == '1') ++cnt;
  29. match[5] = (cmp(s, "94501") == 12 ? '1' : '0'); if (match[5] == '1') ++cnt;
  30. match[6] = (cmp(s, "25349") == 3 ? '1' : '0'); if (match[6] == '1') ++cnt;
  31.  
  32. if (cnt >= 6) printf("%c%c%c%c%c: %s\n", s[0], s[1], s[2], s[3], s[4], match);
  33.  
  34. } while (next_permutation(s, s+10));
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 16064KB
stdin
Standard input is empty
stdout
04639: 1111110
04936: 1111111
04937: 1111011
04965: 1111101
64795: 1110111
74895: 0111111
84795: 0111111