#include <iostream> using namespace std; int main() { int a; cin >> a; for(int x = 0; x <= 14; x++){ if((100 - 7*x) % 4 == 0){ int y = (100-7*x)/4; int z = 100 - x - y; cout << x <<" " << y << " " << z << endl; } } }
解方程思想
5x + 3y + z/3 = 100
x + y + z = 100
可以得到,
y=(100-7x)/4,由此得到x的取值范围去遍历
z=100-x-y