//poj 1302
//sep9
#include <iostream>
using namespace std;
char s[32];
int n;
int f(int cur)
{
if(cur==n||s[cur]=='0'){
return 0;
}
if(s[cur]>='A'&&s[cur]<='Z'){
int t=f(cur+1);
s[cur]=t%10+'0';
return t+1;
}
if(s[cur]>='1'&&s[cur]<='9'){
int t=s[cur]-'0';
--s[cur];
if(cur+t<n)
return f(cur+t)+1;
else
return f(cur+1)+1;
}
}
int main()
{
while(scanf("%s",s)==1){
if(strcmp(s,"ENDOFINPUT")==0)
break;
scanf("%d%s%*s",&n,s);
f(0);
puts(s);
}
return 0;
}
poj 1302 Blue Gene, Jr. 递归
最新推荐文章于 2020-08-14 11:37:31 发布