Runaround Numbers chapter 2.2
2013-08-30 18:00
232 查看
题目看懂了到是不难,直接枚举,不过调错真是调了好久,提交了12次才过啊啊啊啊啊
/* ID: hubiao cave PROG: runround LANG: C++ */ #include<iostream> #include<fstream> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { ifstream fin("runround.in"); ofstream fout("runround.out"); int used[11]={0}; int start; char buf[20]={0}; fin>>start; int i=start; while(1) { memset(buf,0,20); memset(used,0,sizeof(int)*11); ++i; //_itoa(i,buf,10); sprintf(buf,"%d",i); string str=buf; if(str.find('0')!=-1) continue; int m=i; int flag=0; while(m/10>=1) { if(used[m%10]) { flag=1; break; } else { used[m%10]=1; m/=10; } } if(flag) continue; if(used[m]) continue; else { memset(used,0,sizeof(int)*11); int count=0; int sta=0; int starnum=str[0]-'0'; int flag=0; while(count<str.size()-1) { sta=sta+(str[sta]-'0')%str.size(); if(sta>=str.size()) sta%=str.size(); if(used[str[sta]-'0']||sta==0) { flag=1; break; } else { used[str[sta]-'0']=1; } count++; } if(flag) continue; sta=sta+(str[sta]-'0')%str.size(); if(sta>=str.size()) sta%=str.size(); if(sta==0) { fout<<i<<endl; break; } } } return 0; }
相关文章推荐
- USACO Section 2.2: Runaround Numbers
- 2.2Runaround Numbers
- USACO 2.2 Runaround Numbers(乱搞)
- USACO Section2.2 Runaround Numbers 解题报告 【icedream61】
- USACO Section 2.2 Runaround Numbers
- USACO - Chapter2 Section 2.2 - Runaround Numbers
- Section 2.2 Runaround Numbers
- USACO 2.2 Runaround Numbers
- USACO 2.2 Runaround Numbers
- USACO section 2.2 Runaround Numbers
- USACO-Section2.2 Runaround Numbers [其他][模拟]
- USACO section 2.2 Runaround Numbers
- USACO-Section 2.2 Runaround Numbers (枚举)
- USACO Section 2.2 Runaround Numbers
- USACO-Section2.2 Runaround Numbers
- USACO Section 2.2 Runaround Numbers
- USACO Section 2.2 Runaround Numbers
- [USACO2.2]循环数 Runaround Numbers
- [2016/7/26][usaco 2.2]Runaround Numbers
- USACO 2.2 Runaround Numbers (runround)