Untitled
unknown
c_cpp
22 days ago
435 B
3
Indexable
Never
void problemsSolved(int N, int A, int B, int K) { int alisterProblems = 0; // Loop through each problem code from 1 to N for (int i = 1; i <= N; i++) { if (i % A == 0 && i % B != 0) { alisterProblems++; } } // Calculate the absolute difference between K and problems solved by Alister int result = abs(alisterProblems - K); // Output the result printf("%d", result); }
Leave a Comment