题解:P11466 透明立方体
题目传送门
\texttt{Description}
给定一个
\texttt{Solution}
第一部分:最少个数
-
易得每一行、每一列、每一排只需要一个染色,所以最小值即为:
\max(n \times m,n \times k, m\times k) -
又因为
n \ge m \ge k ,所以\max(n \times m, n \times k, m \times k)=n\times m 。
第二部分:方案输出
我们可以直接通过枚举行坐标和列坐标,然后算出第三维的坐标并直接输出即可。注意取模时的负数!
时间复杂度
\texttt{Code}
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n, m, k, x;
cin >> n >> m >> k;
cout << n * m << endl;
for (int i = 1; i <= n; i++) {
x = (k - i + 1 + n) % n;
for (int j = 1; j <= m; j++)
cout << i << " " << j << " " << (x++) % k + 1 << endl;
}
return 0;
}
完结了,拜拜。