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>
- #include<time.h>
- using namespace std;
- vector<int> str;
- set<int> was;
- int getLast() {
- int res = 0;
- for (int i = str.size() - 4; i < str.size(); i++) {
- res *= 10;
- res += str[i];
- }
- return res;
- }
- int main() {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- #endif
- freopen("output.txt", "w", stdout);
- srand(time(0));
- for (int i = 0; i < 4; i++) {
- str.push_back(rand() % 10);
- }
- was.insert(getLast());
- while (was.size() != 10000) {
- bool ok = false;
- for (int i = 0; i < 10; i++) {
- str.push_back(i);
- int val = getLast();
- if (was.count(val) != 0) {
- str.pop_back();
- }
- else {
- ok = true;
- break;
- }
- }
- if (!ok) {
- str.push_back(rand() % 10);
- }
- }
- printf("%d\n", str.size());
- for (auto i : str) {
- printf("%d", str[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement