Files
python/TangDou/LuoGuBook/P2089_2.cpp

50 lines
1.9 KiB
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include<bits/stdc++.h>
using namespace std;
//简化for循环的宏
#define _for(i, a, b) for( int i=(a); i<(b); ++i)
#define _rep(i, a, b) for( int i=(a); i<=(b); ++i)
int main() {
int k, l = 0;
cin >> k;
_rep(a, 1, 3)
_rep(b, 1, 3)
_rep(c, 1, 3)
_rep(d, 1, 3)
_rep(e, 1, 3)
_rep(f, 1, 3)
_rep(g, 1, 3)
_rep(h, 1, 3)
_rep(i, 1, 3)
_rep(j, 1, 3)
if (a + b + c + d + e + f + g + h + i + j == k) l++;
cout << l << endl;
_rep(a, 1, 3)
_rep(b, 1, 3)
_rep(c, 1, 3)
_rep(d, 1, 3)
_rep(e, 1, 3)
_rep(f, 1, 3)
_rep(g, 1, 3)
_rep(h, 1, 3)
_rep(i, 1, 3)
_rep(j, 1, 3)
if (a + b + c + d + e + f + g + h + i + j == k) {
cout << a << " ";
cout << b << " ";
cout << c << " ";
cout << d << " ";
cout << e << " ";
cout << f << " ";
cout << g << " ";
cout << h << " ";
cout << i << " ";
cout << j << endl;
}
return 0;
}