Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: mickyta1
- TASK: runround
- LANG: C++
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef unsigned int uint;
- const int N = 9 + 5;
- bool visited[N];
- int main(){
- freopen("runround.in", "r", stdin);
- freopen("runround.out", "w", stdout);
- int lwb;
- scanf("%d", &lwb);
- for(uint i = lwb + 1; true; ++i){
- string str = to_string(i);
- for(int j = 0; j <= 9; ++j){
- visited[j] = false;
- }
- bool hasDup = false;
- for(int j = 0; j < str.size(); ++j){
- int c = str[j] - '0';
- if(visited[c]){
- hasDup = true;
- break;
- }
- visited[c] = true;
- }
- if(hasDup || visited[0]){
- continue;
- }
- for(int j = 0; j <= 9; ++j){
- visited[j] = false;
- }
- hasDup = false;
- int mve = 0;
- for(int j = 0; j < str.size(); ++j){
- int c = str[mve % str.size()] - '0';
- if(visited[c]){
- hasDup = true;
- break;
- }
- visited[c] = true;
- mve += c;
- }
- if(hasDup || str[mve % str.size()] != str[0]){
- continue;
- }
- cout << str << '\n';
- break;
- }
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement