結果

問題 No.2797 Square Tile
ユーザー kokosei
提出日時 2024-07-06 12:24:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 77,696 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 12:24:51
合計ジャッジ時間 2,059 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
using ll = long long;

int A, B;
int gcd(int a, int b){
    if(b == 0)return a;
    return gcd(b, a % b);
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> A >> B;
    int L = A * A + B * B;
    int g = gcd(A, B);
    L /= g;
    for(int x = 0;x < L * g;x += L){
        for(int y = 0;y < L * g;y += L){
            for(int i = 0;i < L / g;i++){
                cout << x + i * A % L << " " << y + i * B % L << "\n";
            }
        }
    }
    for(int x = 0;x < L * g;x += L){
        for(int y = 0;y < L * g;y += L){
            for(int i = 0;i < L / g;i++){
                cout << x + (i + 1) * A % L << " " << y + i * B % L << "\n";
            }
        }
    }
    return 0;
}
0