Advertisement
Hippskill

Untitled

Jan 27th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include<stdio.h>
  3. #include<iostream>
  4. #include<vector>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<map>
  8. #include<set>
  9. #include<sstream>
  10. #include<cstring>
  11. #include<numeric>
  12. #include<limits.h>
  13. using namespace std;
  14.  
  15.  
  16. set<int> to;
  17.  
  18.  
  19. void found(string cur) {
  20.     to.erase(cur[cur.length() - 1] - '0');
  21.     for (int i = cur.length() - 4; i < cur.length(); i++) {
  22.         for (int len = 1; len <= cur.length() - i; len++) {
  23.             int toDel = 0;
  24.             for (int j = 0; j < len; j++) {
  25.                 toDel *= 10;
  26.                 toDel += cur[i + j] - '0';
  27.             }
  28.             to.erase(toDel);
  29.         }
  30.     }
  31. }
  32.  
  33.  
  34. int main() {
  35. #ifndef ONLINE_JUDGE
  36.     freopen("input.txt", "r", stdin);
  37. #endif 
  38.     for (int i = 0; i <= 9999; i++) {
  39.         to.insert(i);
  40.     }
  41.  
  42.     string cur = "";
  43.     for (int i = 0; i < 4; i++) {
  44.         cur += rand() % 10 + '0';
  45.         to.erase(cur[i] - '0');
  46.     }
  47.     found(cur);
  48.     while (to.size() != 0) {
  49.         int c = rand() % 10;
  50.         cur += c + '0';
  51.         found(cur);
  52.     }
  53.  
  54.  
  55.     printf("%s", cur.c_str());
  56.  
  57.  
  58.    
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement