結果
| 問題 |
No.2797 Square Tile
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-04 13:30:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 872 bytes |
| コンパイル時間 | 2,029 ms |
| コンパイル使用メモリ | 197,836 KB |
| 最終ジャッジ日時 | 2025-02-22 01:56:18 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,l,r) for(int i=(l);i<(int)(r);i++)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int A,B;
cin>>A>>B;
int X=A*A+B*B;
bool swapf=0;
if(A<B){
swap(A,B);
swapf=1;
}
int cnt=0;
vector ansA(0,array<int,2>()),ansB=ansA;
int sx=0,sy=0;
while(cnt<A*A+B*B){
int x=(sx+B)%X,y=(sy+A)%X;
while(x!=sx||y!=sy){
ansA.push_back({x,y});
ansB.push_back({x,(y+A)%X});
cnt+=1;
x=(x+B)%X,y=(y+A)%X;
}
ansA.push_back({sx,sy});
ansB.push_back({sx,(sy+A)%X});
cnt+=1;
sx=((sx+B-A)%X+X)%X,sy=(sy+A+B)%X;
}
if(swapf){
swap(ansA,ansB);
}
for(auto i:ansA){cout<<i[0]<<' '<<i[1]<<'\n';}
for(auto i:ansB){cout<<i[0]<<' '<<i[1]<<'\n';}
}