0

Input

The input begins with two positive integers n k (n, k<=10^7). 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 are divisible by k.
my code is.........

#include<stdio.h>
     
    
    int main()
    {
    int t,i=1,j=0,k;
  int n;
  
    scanf("%d%d", &t,&k);
  if(t>0&&k>0)
  {
    while(i<=t){
    scanf("%d",&n);
   
    if(n%k==0)
    j++;
    i++;
}
    printf("%d",j);
}
    
    return 0;
    }

Whats wrong?

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by Narue
0

will u please give me exampl and its expected output i am not getting your problem

0

Those requirements are odd. Given the ranges of ti and k , I would expect to check if ti evenly divides k , not if ti is divisible by k . Any k larger than 109 in the latter case is completely predictable and need not be checked.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.