結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー nebukuro09nebukuro09
提出日時 2021-07-30 22:07:57
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,085 bytes
コンパイル時間 2,487 ms
コンパイル使用メモリ 106,772 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 13:34:31
合計ジャッジ時間 3,287 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,380 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 WA -
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 1 ms
4,380 KB
testcase_49 WA -
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = 0 ~ readln.split.map!(to!long).array;

    immutable long MOD = 10^^9 + 7;
    long mx = 0; foreach (a; A) mx = max(mx, a);

    if (mx == A.sum) {
        long ans = ((powmod(10, N, MOD) - 1 + MOD) % MOD) * powmod(9, MOD-2, MOD) % MOD;
        foreach (i; 1..10) if (A[i]) ans = ans * i % MOD;
        ans.writeln;
        return;
    }

    bool all_even = iota(1, 10, 2).map!(i => A[i] == 0).all;
    long sm = 0;
    foreach (i; 1..10) sm += A[i] * i;

    if (sm % 9 == 0) {
        writeln(9);
    } else if (sm % 3 == 0) {
        if (all_even) {
            writeln(6);
        } else {
            writeln(3);
        }
    } else {
        writeln(1);
    }
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
0