結果

問題 No.2797 Square Tile
ユーザー GOTKAKO
提出日時 2024-06-28 22:02:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 192,832 KB
最終ジャッジ日時 2025-02-22 01:08:02
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int a,b; cin >> a >> b;

    int tile = a*a+b*b,n = tile;
    int sx = 0,sy = 0,x = 0,y = 0;
    while(tile--){
        cout << x << " " << y << "\n";
        x = (x+a)%n, y = (y+b)%n;
        if(x == sx && y == sy){
            sx = (sx+a-b+n)%n;
            sy = (sy+a+b)%n;
            x = sx; y = sy;
        }
    }
    tile = n;
    sx = a,sy = 0,x = a,y = 0;
    while(tile--){
        cout << x << " " << y << "\n";
        x = (x+a)%n, y = (y+b)%n;
        if(x == sx && y == sy){
            sx = (sx+a-b+n)%n;
            sy = (sy+a+b)%n;
            x = sx; y = sy;
        }
    }
}
0