結果

問題 No.2451 Redistribute Integers
ユーザー InTheBloomInTheBloom
提出日時 2023-09-01 21:25:05
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 4,859 ms
コンパイル使用メモリ 160,724 KB
実行使用メモリ 32,344 KB
最終ジャッジ日時 2023-09-01 21:25:12
合計ジャッジ時間 6,188 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 84 ms
29,192 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 41 ms
12,968 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 55 ms
12,532 KB
testcase_17 AC 85 ms
16,180 KB
testcase_18 WA -
testcase_19 AC 10 ms
5,972 KB
testcase_20 AC 92 ms
15,600 KB
testcase_21 AC 115 ms
30,328 KB
権限があれば一括ダウンロードができます

ソースコード

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