1 / 2
Jan 2020

I have tried this and getting the exact numbers but I dont know why my solution is not getting accepted. I have done in C++ and this is my code


This is a modified code that takes care of extra large digits but the answer is still not accepted.

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <bits/stdc++.h>
#include<limits>
using namespace std;

int main(){
    int b;
    cin>>b;
    int num[b];
    for(int i=0;i<b;i++){
        cin>>num[i];
        if(num[i]>1000000){
            //cout<<"Enter value less than 1000000"<<endl;
            cin.clear();
            cin.ignore(numeric_limits<streamsize>::max(),'\n');
            //cout<<"You have entered wrong input"<<endl;
            cin>>num[i];
        }
    }
    string a[b];
    for(int i=0;i<b;i++){
        long numb = num[i] + 1;

        if(!(numb>1000000 || num[i] <10 )){
            for(int k=numb; k<1000000; k++){
                stringstream ss;
                ss << k;
                string str=ss.str();
                string ostr = str;
                reverse(str.begin(), str.end());
                if(ostr == str){
                    a[i] = ostr;
                    //cout<<ostr<<endl;
                    break;
                }
            }
            cout<<a[i]<<endl;
        }

    }

}
  • created

    Jan '20
  • last reply

    Jan '20
  • 1

    reply

  • 626

    views

  • 2

    users

  • 1

    link

It’s relay so difficult to click in “search topics, posts, user or categories” icon, write here “palin” and find: http://discuss.spoj.com/search?expanded=true&q=palin1 <— then read it all!? :wink:

What this mean: “… positive integer K of not more than 1000000 digits …” !?
|
|
V
positive integer K of not more than 1 digits ==> K < 10
positive integer K of not more than 2 digits ==> K < 100
positive integer K of not more than 3 digits ==> K < 1000

positive integer K of not more than 10 digits ==> K < 10000000000

positive integer K of not more than 1000000 digits mean K < 100000000000000000000 … 0000000000000000000000000000000000000000000000000000000 … 00000000000000000 = 10^1000000 is’n it? :wink:

Then, what are you doing here:

int num[b]; <-------- here!? int !? for number < 10^1000000
    for(int i=0;i<b;i++){
        cin>>num[i];

And do you know what is it and for what:

#include <bits/stdc++.h> //;-)

Search icon =
image on right upper corner of this page :wink:

Suggested Topics

Want to read more? Browse other topics in Online Judge System or view latest topics.