The subject is testing the speed at which the data is read.
If there is a lot of data to read, using CIN is very slow.
So it's a lot quicker to use scanf, but it's not fast enough if the amount of data is bigger.
So use fread here.
Start with a buffer and then read the data very quickly using fread chunks.
The topics are as follows:
Input
The input begins with the positive integers n k (n, k<=107). The next n lines of input contain one positive integer ti, not greater than 109, each.
Output
Write a single integer to output, denoting how many integers ti is divisible by K.
Example
Input:7 31519663697999999611Output:4
Original title Address:
http://www.codechef.com/problems/INTEST/
#include <stdio.h>namespace{#define SIZE 65536}int enormousinputtest () {char buffer[size];unsigned n, K, c;scanf ( "%u%u\n", &n, &k); unsigned ans = 0;int num = 0;while ((c = fread (buffer, 1, SIZE, stdin)) > 0) {for (unsigned I = 0; I < C; i++) {if (buffer[i] = = ' \ n ') {if (num% k = = 0) ans++;num = 0;} Else{num = num * + buffer[i]-' 0 ';}} printf ("%u", ans); return 0;}
Testing this function is too fast.