Enormous Input test Codechef Solution in C language with logic
Let first we discuss some topic.
Increment and decrement operators
i++ (i is increased by 1)
i-- (i is decreased by 1)
printf(“—i=%d”,--i);
This first decrements i and then prints it
printf(“i--=%d”,i--);
This first prints i and then decrements it
1. +++ operators does not exists => Important
2. += is compound assignment operator just like -=, *=, /= & %= =>Also important
here the code-->
#include <stdio.h>
int main() {
int n, k;
scanf("%d %d", &n, &k);
int ans = 0;
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
if (t % k == 0) {
ans++;
}
}
printf("%d\n", ans);
return 0;
}
and then use custom input, used data provided by codechef in question.
So now discuss the logic we only need to remove the (" using namespace std; ")
because “using namespace std” means in programming languages we use the namespace named std. “std” is an abbreviation for standard. So that means we use all the things with in “std” namespace. If we don't want to use this line of code, we can use the things in this namespace like this. std::cout, std::endl
so this is the reason you got error in your earlier submission :).
Comments
Post a Comment
If you have any doubts let me know