UVA 12050 - Palindrome Numbers

UVA Sep 1, 2020

Problem PDF

Solution:

/******************************************************************
***   Author        : Shipu Ahamed (Psycho Timekiller)          ***
***   E-mail        : [email protected]                   ***
***   University    : BUBT,Dept. of CSE                         ***
***   Team          : BUBT_HIDDEN                               ***
***   Facebook      : http://www.facebook.com/DeesheharaShipu   ***
******************************************************************/

#include 
using namespace std;

typedef  vector vi;

#define ll long long
#define pb push_back

////============ CONSTANT ===============////
#define mx  30
////====================================////

ll pal[mx];

void palindrome()
{
    pal[1]=9;
    pal[2]=9;
    ll range=18;
    for(int len=3;len2000000000)
        break;
    }
}

int main()
{
    palindrome();
    ll n;
    while(scanf("%lld",&n))
    {
        if(n==0) break;
        vi v;
        for(int i=1;i<=mx;i++)
        {
            if(n<=pal[i])
            {
                int m;
                if(i%2)
                    m=(i+1)/2;
                else
                    m=i/2;

                for(int j=0;j=0;l--)
                    v.pb(v[l]);

                break;
            }
            else
                n=n-pal[i];
        }
        int s=v.size();

        for(int i=0;i
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/12050/12050.cpp

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.