intest:enormous input

import java.util.Scanner;

class test { 
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int count=0;
        int o1=sc.nextInt();
        int o2=sc.nextInt();
        
        while(o1>0)
        {
            int o3=sc.nextInt();

            
            if(o3%o2==0)
            {
                count++;
            }
            
            o1--;
            
        }
        
        System.out.println(count);
        
    }
}

can any1 pls help me out why dis is code is exceeding time limit ???

Read this. In java you should use BufferedReader instead of scanner; Also instead of printing with System.out.println you should use BufferedWriter. You should also be familiar with StringTokenizer in order to use BufferedReader properly. In this problem System.out.println should do but it won’t be enough on most problems here where you’ll have to print a LOT of stuff in a single input. Refer to this thread.

1 Like

Thanx a lot i’ll work on it…!

//