Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include<stdio.h>
- #include<iostream>
- #include<vector>
- #include<cmath>
- #include<algorithm>
- #include<map>
- #include<set>
- #include<sstream>
- #include<cstring>
- #include<numeric>
- #include<limits.h>
- using namespace std;
- set<int> to;
- void found(string cur) {
- to.erase(cur[cur.length() - 1] - '0');
- for (int i = cur.length() - 4; i < cur.length(); i++) {
- for (int len = 1; len <= cur.length() - i; len++) {
- int toDel = 0;
- for (int j = 0; j < len; j++) {
- toDel *= 10;
- toDel += cur[i + j] - '0';
- }
- to.erase(toDel);
- }
- }
- }
- int main() {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- #endif
- for (int i = 0; i <= 9999; i++) {
- to.insert(i);
- }
- string cur = "";
- for (int i = 0; i < 4; i++) {
- cur += rand() % 10 + '0';
- to.erase(cur[i] - '0');
- }
- found(cur);
- while (to.size() != 0) {
- int c = rand() % 10;
- cur += c + '0';
- found(cur);
- }
- printf("%s", cur.c_str());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement