CodeChef-Enormous Input Test

using System;

public class Program
{
   public static void Main()
   {
      string lines = Console.ReadLine();
      string[] splitLines = lines.Split(' ');

      int n = int.Parse(splitLines[0]);
      int k = int.Parse(splitLines[1]);
      int[] t = new int[n];
      int output = 0;

      for(int i = 0; i < n; i++)
      {
         t[i] = int.Parse(Console.ReadLine());
      }

      foreach(int i in t)
      {
         if(i % k == 0)
         {
            output++;
         }
      }

      Console.WriteLine(output);
   }
}

I’m now officially addicted to CodeChef. These problems are so much fun. This is my solution to another beginner problem. In this one, the user inputs two integers separated by a space(hints the split with a ‘ ‘ on line 8). The first integer is ‘n’ and it indicates how many numbers are going to be tested. The second integer is ‘k’ and this is going to be used to find out if each subsequent integer is a multiple of ‘k’.

Here’s a link to the problem.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s