Usaco Section2.2 runaround Numbers Problem Solving report "Icedream61"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.