Hi guys,
i tried to improve total execution time by using a faster method than BufferedReader and BufferedInputStream(both of which were accepted) and got time limit exceeded instead.
the code is similar to that of ‘martins’ submission.
import java.io.IOException;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args) throws IOException {
PrintWriter pw = new PrintWriter(System.out,true);
byte[] arr = new byte[8192];
int cread,n=0,k=0;
while((cread = System.in.read())!=32)
n=n*10+cread-48;
while((cread=System.in.read())!=10)
k=k*10+cread-48;
//pw.println(n+ " " +k);
int count=0;
while((cread=System.in.read(arr,0,8192))>-1)
{
int i=0;
byte b;
while(i<cread)
{
int num=0;
b=arr[i];
while(b!=10)
num=num*10+b-48;
if(num%k==0)
count++;
i++;
}
}
pw.println(count);
}
}
even the use of byte array is not effective.Plz help.