Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Last active December 18, 2018 15:57
Show Gist options
  • Save ammarfaizi2/94a7fdd8a71a855068395e80f4476a14 to your computer and use it in GitHub Desktop.
Save ammarfaizi2/94a7fdd8a71a855068395e80f4476a14 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <stdlib.h>
int
main(int argc, char const *argv[])
{
int q, i, j, w, x, y, z;
FILE *h = fopen("/tmp/input.txt", "r");
char *r9 = (char*)malloc(32 * sizeof(char));
fgets(r9, 32, h);
q = atoi(r9);
for (i = 0; i < q; ++i) {
fgets(r9, 32, h);
w = atoi(r9);
fgets(r9, 32, h);
y = atoi(r9);
fgets(r9, 32, h);
x = atoi(r9);
for (z=0,j=w; j <= y; ++j) {
if ((j % x) == 0) {
z++;
}
}
printf("case %d: %d\n", i, z);
}
free(r9); r9 = nullptr;
fclose(h);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment