标签:page etc examples rap org The ons review ref
#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 << ‘\n‘; } 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("\n"); } }
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid
标签:page etc examples rap org The ons review ref
原文地址:https://www.cnblogs.com/Shallow-dream/p/11870142.html