Enormous Input Test

sookie

sookie

@sookie-T06sFW Oct 22, 2024
Hi All,

This if for all crazy programming enthusiasts existing over here.

The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.

Input
The input begins with two positive integers n k (n, k<=10[sup]7[/sup]). The next n lines of input contain one positive integer t[sub]i[/sub], not greater than 10[sup]9[/sup], each.

Output
Write a single integer to output, denoting how many integers t[sub]i[/sub] are divisible by k.

Example
Input:
7 3
1
51
966369
7
9
999996
11

Output:
4

Source: <a href="https://www.codechef.com/problems/INTEST/" target="_blank" rel="nofollow noopener noreferrer">INTEST Problem | CodeChef</a>

I am soon going to come back with my program. Looking forward for many good posts in this thread over here.

Thanks !

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Aug 15, 2009

    Cool. I'm assuming there are no restrictions over the choice of programming/scripting language.
  • sookie

    sookie

    @sookie-T06sFW Aug 15, 2009

    The_Big_K
    Cool. I'm assuming there are no restrictions over the choice of programming/scripting language.
    Just have a look at their site once for restrictions.

    Here is my program. I submitted it in their site also but those folks are still living in the world of JDK1.5 so my JDK1.6 made program showed compiler error in their system. Anyway, Please you people review my program and tell what all optimizations I can do in it.

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package myjava;
    
    import java.io.DataInputStream;
    import java.io.IOException;
    
    /**
     *
     * @author sookie
     */
    public class EnormousInputTest {
    
        public static void main(String[] args) {
    
            String num[];
            int n, k, count = 0;
    
            try {
                DataInputStream din = new DataInputStream(System.in);
                num = din.readLine().split(" ");
                n = Integer.parseInt(num[0]);
                k = Integer.parseInt(num[1]);
                for (int i = 0; i < n; i++) {
                    if (Integer.parseInt(din.readLine()) % k == 0) {
                        count++;
                    }
                }
                System.out.println("Output:\n" + count);
            }catch (IOException e) {
                System.out.println("IO Exception occured");
            }catch (Exception e) {
                System.out.println("Invalid data entered");
            }
        }
    }
    
    Thanks !
  • sookie

    sookie

    @sookie-T06sFW Aug 21, 2009

    No replies(neither reviews nor programs) yet ? Surprising ! :shock:
  • pradeep_agrawal

    pradeep_agrawal

    @pradeep-agrawal-rhdX5z Aug 21, 2009

    This is simple and straight forward program. Not scope of much improvement.

    -Pradeep