BUPT-homework/pset6/1-soldiers.c
2021-11-01 20:25:24 +08:00

35 lines
680 B
C

#include <stdio.h>
int main(void) {
// Initialize variables
int n;
scanf("%d", &n);
// Start looping
int sum;
int found = 0;
for (int a = 0; found != 1; a++) {
sum = a * 5 + 1;
for (int b = 0; sum >= b * 6 + 5; b++) {
if (sum != b * 6 + 5) { // The sum don't equal
continue;
}
for (int c = 0; sum >= 7 * c + 6; c++) {
if (sum != 7 * c + 6) {
continue;
}
for (int d = 0; sum >= 11 * d + 10; d++) {
if (sum != 11 * d + 10) {
continue;
}
if (sum >= n) {
printf("%i\n", sum);
found = 1;
}
}
}
}
}
return 0;
}