Palindrome Numbers (LA2889) The nth palindrome number is?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.