跳到正文

题解

P11466题解

I__________________I约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年12月26日
收录
2026年5月22日
更新
2026年9月11日
篇幅
约 2 分钟
题目
P11466

版本

  1. v1当前
C++
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LL long long
#define ull unsigned long long
#define N 55
const ll mod = 998244353;
const ll inf = 1e17;
const ll INF = 1e9 + 7;
const double eps = 1e-8;
const ll Mod = (1e9 + 7);

inline ll read()
{
    ll f = 0, g = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){if (ch == '-') g = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9')
    f = (f << 1) + (f << 3) + (ch ^ 48), ch = getchar();
    return f * g;
}
int xy[N][N];
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=a;i++)
    {
        int start=(c-i+1+a)%a;
        for(int j=1;j<=b;j++)
        {
            xy[i][j]=start%c+1;
            start++;
        }
    }
    cout<<a*b<<'\n';
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
           cout<<i<<' '<<j<<' '<<xy[i][j]<<'\n';
        }
    }
}

1.先思考把三维立体二维化 x>y>z

用一个xy[N][N]数组维护, xy坐标下,我要染黑的方块对应的z坐标

2.xy数组要保证,每行每列都出现1~Z且每个位置非空。

例子:x=5,y=4,z=3

xy数组

1231
3123
2312
1231
3123
原文