J-palindrome Numbers
Time Limit: 3000MS Memory Limit:0KB 64bit IO Format:%lld &%llu
SubmitStatus Practiceuvalive 2889WA A page, I was also drunk, because a compilation environment is different ... say more is a tear. Topic Link: Please click uvalive 2889Reprint Please specify the Source:Looking for Children & stars
#include <stdio.h> #define LL long long#define MM 2000000000LL num[25]= {0}; ll Ppow (ll X,ll y) {ll tp=1; while (y--) {tp*=x; } return TP;} void Init () {LL tp=9,i; for (i=1;;) {NUM[I]=NUM[I-1]+TP; i++;//counterparts have multiple I to deal with the time I, do not put i++ inside, because the variation of the environment different, the sequence of operations may be WA NUM[I]=NUM[I-1]+TP; i++; tp=tp*10; if (num[i-1]>=mm) break; }/* for (int i=1;i<21;i++) {LL p= (i+1)/2-1; Num[i]=num[i-1]+9*ppow (10,P); printf ("%lld\n", Num[i]); }//printf ("%lld\n", Num[0]); */}int main () {init (); LL N; LL A[20]; while (scanf ("%lld", &n), n) {int len=0; for (int i=1; i<=20; i++) {if (N<=num[i]) {len=i; Break }}//printf ("len=%d\n", Len); LL M=n-num[len-1]; int l= (len+1)/2;//printf ("m=%lld\tl=%d\n", m,l); LL Ans=ppow (10,L-1) +m-1;//printf ("ans=%lld\tppow=%lld\n", ans,pPow (10,L-1)); printf ("%lld", ans); if (len&1) ans/=10; while (ans) {printf ("%lld", ans%10); ans/=10; } printf ("\ n"); } return 0;}
Palindrome Numbers (LA2889) The nth palindrome number is?