Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid
Posted shallow-dream
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid相关的知识,希望对你有一定的参考价值。
#include<bits/stdc++.h> using namespace std; #define int long long const int MAXN = 2e3 + 7; int ans[MAXN][MAXN]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n / 4; ++i) { for (int j = 0; j < n / 4; ++j) { ans[4 * i][4 * j] = 8 + i * 4 * n + 16 * j; ans[4 * i][4 * j + 1] = 9 + i * 4 * n + 16 * j; ans[4 * i][4 * j + 2] = 1 + i * 4 * n + 16 * j; ans[4 * i][4 * j + 3] = 13 + i * 4 * n + 16 * j; ans[4 * i + 1][4 * j] = 3 + i * 4 * n + 16 * j; ans[4 * i + 1][4 * j + 1] = 12 + i * 4 * n + 16 * j; ans[4 * i + 1][4 * j + 2] = 7 + i * 4 * n + 16 * j; ans[4 * i + 1][4 * j + 3] = 5 + i * 4 * n + 16 * j; ans[4 * i + 2][4 * j] = 0 + i * 4 * n + 16 * j; ans[4 * i + 2][4 * j + 1] = 2 + i * 4 * n + 16 * j; ans[4 * i + 2][4 * j + 2] = 4 + i * 4 * n + 16 * j; ans[4 * i + 2][4 * j + 3] = 11 + i * 4 * n + 16 * j; ans[4 * i + 3][4 * j] = 6 + i * 4 * n + 16 * j; ans[4 * i + 3][4 * j + 1] = 10 + i * 4 * n + 16 * j; ans[4 * i + 3][4 * j + 2] = 15 + i * 4 * n + 16 * j; ans[4 * i + 3][4 * j + 3] = 14 + i * 4 * n + 16 * j; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cout << ans[i][j] << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (ans > n * n - 1) ans = 1; cout << ans << ‘ ‘; ans += 2; } cout << ‘ ‘; } return 0; }
#include <iostream> using namespace std; int c[1002][1002]; int main() { int n; cin >> n; for(int i = 0; i < n / 4; i++){ for(int j = 0; j < n / 4; j++){ for(int k = 0; k < 4; k++){ for(int l = 0; l < 4; l++){ c[i * 4 + k][j * 4 + l] = i * (n * 4) + j * 16 + k * 4 + l; } } } } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%d ", c[i][j]); } printf(" "); } }
以上是关于Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid的主要内容,如果未能解决你的问题,请参考以下文章
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)B(SET)
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) (1208F,1208G,1208H)