結果

問題 No.2451 Redistribute Integers
ユーザー InTheBloom
提出日時 2023-09-01 21:25:05
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 3,777 ms
コンパイル使用メモリ 173,440 KB
実行使用メモリ 28,184 KB
最終ジャッジ日時 2024-06-11 10:57:50
合計ジャッジ時間 5,880 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N = readln.chomp.to!int;
    int[] A = readln.split.to!(int[]);

    solve(N, A);
}

void solve (int N, int[] A) {
    // 一つの要素から N-2 を引くともとらえられるので、限界まで引いたらいい。
    if (N != 2) {
        foreach (ref a; A) {
            a %= N-2;
            if (a < 0) {
                a += N-2;
            }
        }
    }

    foreach (a; A) {
        if (a != A[0]) {
            writeln("No");
            return;
        }
    }

    writeln("Yes");
}
0