Professional Documents
Culture Documents
Codechef Beginner qn5
Codechef Beginner qn5
C Programming
Code-Chef Submission
QUESTION: 5: INTEST
BEGINNER
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.
//ANANDHA KRISHNAN.R
#include <stdio.h>
int main() {
int n, k;
scanf("%d %d", &n, &k);
int div = 0;
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
if (t % k == 0) {
div++;
}
}
printf("%d\n", div);
return 0;
}
APPROACH:
Two numbers ‘n’ and ‘k’ are entered ,’div’ is initialised to 0.using for
loop the program is executed n times and then number ‘t’ is entered
and if t is divisible by k the value of div gets incremented by 1 unit
and is printed onto the screen .If all the program constraints are true
then 2.5MB of input data is processed at runtime.