I have been getting NZEC for many problems.I can't find the overflows which are held accountable for NZEC.I am getting correct results even for the boundary cases on my machine.Plzz suggest what is going wrong.
Some of the problems showing NZEC are:
http://www.spoj.pl/problems/ETF/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out));
int test=Integer.parseInt(br.readLine());
int i=0,j=0,k=0,k1=0;
int num=0,res=0;
int[] fact;
boolean[] arr;
for(i=0;i<test;i++)
{
res=0;
k=0;
num=Integer.parseInt(br.readLine());
arr=new boolean[num+1];
fact=new int[num+1];
for(j=2;j*j<=num;j++)
{
if(num%j==0)
{
fact[k++]=j;
arr[j]=true;
res++;
fact[k++]=num/j;
arr[num/j]=true;
res++;
}
}
j--;
if(Math.sqrt(num)==j)
{
k=k-1;
res=res-1;
}
for(j=0;j<k;j++)
{
k1=2;
while(fact[j]*k1<num)
{
if(!arr[fact[j]*k1])
{
arr[fact[j]*k1]=true;
res++;
}
k1++;
}
}
if(num==1)
{
pw.println(1);
}
else
{
pw.println(num-res-1);
}
}
pw.flush();
// TODO code application logic here
}
}
https://www.spoj.pl/problems/DIVSUM/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int i=0,j=0;
int num=0;
int sum=1;
int test=Integer.parseInt(br.readLine());
for(i=0;i<test;i++)
{
sum=1;
num=Integer.parseInt(br.readLine());
for(j=2;j<=Math.sqrt(num);j++)
{
if(num%j==0)
{
if(j!=(num/j))
{
sum=sum+j+(num/j);
}
else
{
sum+=j;
}
}
}
System.out.println(sum);
}
// TODO code application logic here
}
}
https://www.spoj.pl/problems/TWOSQRS/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out));
int test=Integer.parseInt(br.readLine());
int i=0,j=0,pow=0;
long num=0,numb=0;
for(i=0;i<test;i++)
{
num=Long.parseLong(br.readLine());
if(num==0)
{
pw.println("Yes");
continue;
}
numb=num;
pow=0;
while(num%2==0)
{
pow++;
num/=2;
}
j=3;
boolean b=false;
while(num>1 && j<=numb)
{
pow=0;
while(num%j==0)
{
pow++;
num/=j;
}
if(j%4==3 && pow%2!=0)
{
pw.println("No");
b=true;
break;
}
j=j+2;
}
if(!b)
{
pw.println("Yes");
}
}
pw.flush();
// TODO code application logic here
}
}