1 /* 2 PROG: runround 3 ID: jiafeim1 4 LANG: C++ 5 */ 6 7 8 #include < iostream > 9 #include < fstream > 10 11 using namespace std; 12 13 unsigned long res; 14 15 unsigned long decX[ 11 ] = { 1 , 10 , 100 , 1000 , 10000 , 100000 , 1000000 , 10000000 , 100000000 }; 16 bool check(unsigned long num) 17 { 18 bool haveDo[ 11 ] = { false }; 19 bool haveDoNum[ 11 ] = { false }; 20 int l = 0 ; 21 unsigned long temL = num; 22 while (temL) 23 { 24 if (temL % 10 == 0 ) return false ; 25 ++ l; 26 temL /= 10 ; 27 28 } 29 unsigned long cur = 0 ; 30 unsigned long temp; 31 32 for ( int now = 1 ;now <= l; ++ now) 33 { 34 if (haveDo[cur]) return false ; 35 temp = (num / decX[l - cur - 1 ]) % 10 ; 36 if (haveDoNum[temp]) return false ; 37 haveDo[cur] = true ; 38 haveDoNum[temp] = true ; 39 cur = (temp + cur) % l; 40 } 41 if (cur != 0 ) return false ; 42 return true ; 43 } 44 45 int main() 46 { 47 std::ifstream fin( " runround.in " ); 48 std::ofstream fout( " runround.out " ); 49 50 int n; 51 52 fin >> n; 53 for (res = n + 1 ;; ++ res) 54 { 55 if (check(res)) 56 { 57 fout << res << endl; 58 break ; 59 } 60 61 } 62 63 fin.close(); 64 fout.close(); 65 66 }