Created
April 20, 2019 17:27
-
-
Save Lulzx/d0e1e0975078cee736db452e82a0f3ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int count(int l, int r, int n, int m) | |
{ | |
int count = 0; | |
for (int i = l; i <= r; i++) { | |
int sum = 0, x = i, t; | |
t = (i % m); | |
while (x != 0) { | |
sum += x % 10; | |
x /= 10; | |
} | |
if (!(t) && sum == n) | |
count++; | |
} | |
return count; | |
} | |
int main() | |
{ | |
int l, r, n, m; | |
scanf("%d\n%d\n%d\n%d", &l, &r, &n, &m); | |
printf("%d\n", count(l, r, n, m)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment