You are not logged in. Please login at www.codechef.com to post your questions!

×

# Runtime Error(NZEC)

 0 Why am I getting this error for my code on the problem The Next Palindrome (http://www.codechef.com/problems/PALIN) import java.io.*; public class Main { public static void main(String[] args)throws IOException { int i; long k; int j; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); System.out.println("Input:"); i=Integer.parseInt(br.readLine()); long arr[]=new long[i]; for(j=0;j0) { sum=sum*10; dig=n2%10; sum+=dig; n2=n2/10; } if(sum==n) return true ; else return false; } }  asked 21 Jun '13, 23:18 shantanujswl 1●1●1 accept rate: 0% argonaut 891●3●9●20

 1 The integer K in the problem statement has upto 1000000 digits. You cannot save it in long (as you are trying to do). That causes RTE. answered 21 Jun '13, 23:24 aichemzee 422●6●12●24 accept rate: 3% 1 Also you don't have to print useless stuff like "Input:" or "Output:". That would get you WA even if your implementation was right. (21 Jun '13, 23:26) aichemzee Oh ,so what do I save it in,isnt long the largest data type in Java.Also,when you say not to print ,what exactly do I have to output then? (21 Jun '13, 23:58) shantanujswl 1 @shantanujswl Use Strings to save the numbers, or Biginteger (If the time limit is not very strict). You just have to print the answer to each case. That's it. No need to print "Input:" or "Output:". They were used in the problem statement to differentiate the input part from the output part (22 Jun '13, 00:25) aichemzee Thank you,new to codechef (22 Jun '13, 07:36) shantanujswl
 toggle preview community wiki

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Tags:

×50
×46

Asked: 21 Jun '13, 23:18

Seen: 304 times

Last updated: 22 Jun '13, 08:41