結果

問題 No.443 GCD of Permutation
ユーザー xuzijian629xuzijian629
提出日時 2018-11-07 02:12:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 879 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 201,192 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 22:21:33
合計ジャッジ時間 2,774 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,944 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    string s;
    cin >> s;
    i64 sum = 0;
    int cnt[10] = {};
    for (char c: s) {
        sum += c - '0';
        cnt[c - '0']++;
    }

    i64 ans = 1;
    if (sum % 9 == 0) {
        ans *= 9;
    } else if (sum % 3 == 0) {
        ans *= 3;
    }

    for (int i = 0; i < 10; i++) {
        if (cnt[i] == s.size()) {
            cout << s << endl;
            return 0;
        }
    }

    if (cnt[0] + cnt[5] == s.size()) {
        cout << 5 << endl;
        return 0;
    }

    int e = 0;
    for (int i = 0; i < 10; i += 2) {
        e += cnt[i];
    }
    if (e == s.size()) {
        if (cnt[0] + cnt[4] + cnt[8] == s.size()) {
            ans *= 4;
        } else {
            ans *= 2;
        }
    }

    cout << ans << endl;
}
0