7 条题解
-
5
AC代码,放心使用
#include <iostream> using namespace std; int main() { int a, b, c, d; int n, m; cin >> n >> m; for (c = 0; c <= n; c += 3) { d = c / 3; for (b = 0; b <= n; b += 1) { for (a = 0; a <= n; a += 1) { if ((a + b + c == m) && (5 * a + 3 * b + d == n)) { cout << a << " " << b << " " << c << endl; } } } } return 0; }
-
2
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; for (int i = 0; i <= m; i++) { for (int j = 0; j <= m; j++) { int k = m - i - j; if (i * 5 + j * 3 + k / 3 * 1 == n && k % 3 == 0) cout << i << " " << j << " " << k << endl; } } return 0; }//以AC
-
0
#include<bits/stdc++.h> using namespace std; int main() { int a, b, c; int n, m; cin >> n >> m; for (a = 0; a <= n/5; a += 1) { for (b = 0; b <= n/3; b += 1) { c = (n - 5*a - 3*b)*3; if (a + b + c == m && c % 3 == 0) { cout << a << " " << b << " " << c << endl; } } } return 0; } 不超时
- 1
信息
- ID
- 78
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 4
- 标签
- 递交数
- 165
- 已通过
- 77
- 上传者