1 / 4
Jan 2011

Every time i send these problem i got WA i don't why frowning

this is code

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std ;
bool isPlaindroom(string word)
{
	for ( int i = 0; i < (word.length()/2); i++)
        if (word[i] != word[(word.length()-1)-i])
            return false;
    return true;
}
string convertInt(long int number)
{
   stringstream ss;//create a stringstream
   ss << number;//add number to the stream
   return ss.str();//return a string with the contents of the stream
}
int GetNextpalindrome(long int Start)
{
	while (true)
	{
		Start = ++Start;
		if (isPlaindroom(convertInt(Start)))
			break;
	}
	return Start;
}
int main()
{
	int x;
	cin>>x;
	long int m;
	vector<int>v;
	for (int i = 0 ; i < x ; i ++)
	{
		cin>>m;
		v.push_back(GetNextpalindrome(m));
	}
	for (int i =0 ; i < v.size(); i ++)
	{
		cout<<v[i]<<endl;
	}
	return 0;
}

Please help frowning

  • created

    Jan '11
  • last reply

    Jan '11
  • 3

    replies

  • 206

    views

  • 3

    users

That doesn't fit in a 32 bit signed integer.

For 90% You will get TLE after fixing WA so don't build your hopes on getting AC.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 16 8d

Want to read more? Browse other topics in C and C++ or view latest topics.