Skip to content

Instantly share code, notes, and snippets.

@Lulzx
Created April 20, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lulzx/d0e1e0975078cee736db452e82a0f3ac to your computer and use it in GitHub Desktop.
Save Lulzx/d0e1e0975078cee736db452e82a0f3ac to your computer and use it in GitHub Desktop.
#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