Runround Problem Solving Report
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Topic
Give you a number m to find the first number of loops larger than it.
Number of loops: not including 0, no repeating number, and a positive integer with cyclic properties.
Cyclic properties: Take 81362 as an example
1. Find the highest level, is 8, then the number of 8, followed by 1,3,6,2,8,1,3,6
2. Now is 6, then continue to the number 6, is 2,8,1,3,6,2
3. Now is 2, number 2, is 8,1
4. It is now 1, 1 digits, 3
5. Now is 3, number 3, is 6,2,8
6. Now back to 8, and each number is exactly 1 times, the number has a cyclic nature.
"Data Range"
M is the natural number of the 1~9 bit, and the answer must be filled with an unsigned long plastic.
"Input Sample"
81361
"Output Example"
81362
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Analysis
There's nothing to say, just do it.
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Summary
Today, the spirit is not focused, ignoring the small details, not a single AC.
--------------------------------------------------------------------------------------------------------------- ---------------------------------
Code
1 /*2 id:icedrea13 Prob:runround4 lang:c++5 */6 7#include <iostream>8#include <fstream>9 using namespacestd;Ten One BOOLOkLong Longnum) A { - intL=0, d[ -]; - BOOLmark[ -]={},have[Ten]={}; the while(num) {d[l++]=num%Ten; Num/=Ten; } - for(intI=0; i!=l;++i) - if(have[d[i]]| | d[i]==0)return false; - Elsehave[d[i]]=true; + - inti=l-1, s=1; mark[i]=true; + while(s<l) A { at intk=D[i]; -I= (i-k+l* -)%l; - if(Mark[i])return false; -mark[i]=true; ++s; - } - intk=D[i]; inI= (i-k+l* -)%l; - returni==l-1; to } + - intMain () the { *Ifstreaminch("runround.in"); $Ofstream out("Runround.out");Panax Notoginseng - Long Longm,i; the + inch>>M; A for(i=m+1;! OK (i); + +i); the out<<i<<Endl; + - inch. Close (); $ out. Close (); $ return 0; -}
Usaco Section2.2 runaround Numbers Problem Solving report "Icedream61"