#include<stdio.h> #include<string.h> int main() { char x[100000][100]; int i,j; x[1][0]='2';x[1][1]='3';x[1][2]='\0'; x[2][0]='1';x[2][1]='2';x[2][2]='8';x[2][3]='\0'; for(i=3;i<=100000;i++) { int a[100]={0}; int t=0; int len=strlen(x[i-1]); for(j=len-1;j>=0;j--) { a[t]+=x[i-1][j]-'0'; if(j==len-1) a[t]+=5; else if(j==len-3) a[t]+=1; if(a[t]>=10) {a[t]-=10;a[t+1]++;if(j==0) t++;} t++; } int T=t; for(j=0;j<T&&t>=0;j++) { x[i][j]=a[--t]+'0'; } x[i][j]='\0'; } int n; while(scanf("%d",&n)!=EOF) { puts(x[n]); } return 0; } |
Double click to view unformatted code.