37 lines
647 B
C
37 lines
647 B
C
|
#include <math.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
// Function prototype
|
||
|
int checkf(float f);
|
||
|
|
||
|
int main(void) {
|
||
|
// Initialize variables
|
||
|
int m, n;
|
||
|
int b, c; // a -> 1, b -> 2 etc.
|
||
|
float a, d; // a -> 1, b -> 2 etc.
|
||
|
scanf("%i%i", &m, &n);
|
||
|
|
||
|
// Start brute forcing
|
||
|
for (b = 0; b <= n; b++) {
|
||
|
for (c = 0; c <= n; c++) {
|
||
|
d = (float)(n - m - b - c * 2) / 3;
|
||
|
if (checkf(d)) {
|
||
|
a = (float)(2 * m - n + c + d * 2);
|
||
|
if (checkf(a)) {
|
||
|
printf("%i %i %i\n", b, c, (int)d);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int checkf(float f) {
|
||
|
if (floorf(f) == f && f >= 0) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|