Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
是个水题,注意一點只需要做一次mutation就输出,不是要等到stabilized。题目叙述和样例不符 #include <iostream> #include <string> using namespace std; int len; string str; int mutate(int start){ if(start >= len) return 0; if(str[start] == '0') return 0; if(str[start] >= 'A'){ int num = mutate(start+1); str[start] = num%10 + '0'; return num+1; } else{ str[start]--; int num = 1; int pos = start + (str[start]+1-'0'); if(pos >= len) pos = start+1; num += mutate(pos); return num; } } int main() { string fei; while(1){ cin >> fei; if(fei == "ENDOFINPUT") break; cin >> len; cin >> str >> fei; mutate(0); cout << str << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator