結果
問題 | No.2797 Square Tile |
ユーザー |
👑 ![]() |
提出日時 | 2024-06-19 04:42:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 2,148 ms |
コンパイル使用メモリ | 202,356 KB |
最終ジャッジ日時 | 2025-02-21 23:17:30 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int A, B; cin >> A >> B; vector<pair<int, int>> X, Y; bool rev = 0; if (A > B) swap(A, B), rev = 1; int P = 0, Q = 0; int L = A * A + B * B; set<pair<int, int>> s; while (!s.count({P, Q})){ while (!s.count({P, Q})){ s.insert({P, Q}); X.push_back({P, Q}); Y.push_back({(P + A) % L, Q}); P = (P + L - B) % L; Q = (Q + A) % L; } P = (P + A) % L; Q = (Q + B) % L; } if (rev) swap(X, Y); for (auto x : X) cout << x.first << " " << x.second << "\n"; for (auto y : Y) cout << y.first << " " << y.second << "\n"; }