| ||||||||||
| 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 | |||||||||
What's wrong? PROB ; 2402
#include <fstream.h>
#include <stdio.h>
#include <string.h>
int N;
char Ans[30];
int main (){
int i, u;
for (;;){
cin >> N;
if (!N) return 0;
for (i=1, u=0;;i*=10, u++){
if (N<i*18) break;
N-=i*18;
}
if (N>i*9){
N-=i*9, N=(i-1)+N;
sprintf ( Ans, "%d", N );
for (i=0; Ans[i]; i++) cout << Ans[i];
for (i--; i>=0; i--) cout << Ans[i];
}
else{
N=(i-1)+N;
sprintf ( Ans, "%d", N );
for (i=0; Ans[i]; i++) cout << Ans[i];
for (i-=2; i>=0; i--) cout << Ans[i];
}
cout << 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