結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー KudeKude
提出日時 2021-07-30 22:48:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,661 bytes
コンパイル時間 4,384 ms
コンパイル使用メモリ 262,152 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-14 07:10:06
合計ジャッジ時間 7,348 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint1000000007;

int n;
int c[11];
int solve() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int cs = 0;
    rep(i, 10) cs += c[i] > 0;
    if (cs == 1) {
        rep(i, 10) if (c[i]) {
            return ((mint(10).pow(n) - 1) / 9 * i).val();
        }
        return 0;
    }
    if (n <= 3) {
        ll g = 0;
        string s;
        rep(i, 10) s.append(c[i], '0' + i);
        do {
            g = gcd(g, stoll(s));
        } while(next_permutation(all(s)));
        return g;
    }

    if (c[3] + c[6] + c[9] == n) {
        int r = (c[3] + 2LL * c[6] + 3LL * c[9]) % 9;
        if (r % 9 == 0) return 27;
        else if (r % 3 == 0) return 9;
        else return 3;
    }
    int r9 = 0;
    rep(i, 10) r9 = (r9 + (ll)i * c[i]) % 9;
    bool b2 = true, b4 = true;
    rep(i, 10) {
        if (i % 2 && c[i]) b2 = false;
        if (i % 4 && c[i]) b4 = false;
    }
    int g = 1;
    if (r9 % 3 == 0) g *= 3;
    if (r9 % 9 == 0) g *= 3;
    if (b2) g *= 2;
    if (b4) g *= 2;
    return g;
}

int main() {
    cin >> n;
    rep(i, 9) cin >> c[i + 1];
    cout << solve() << endl;
}
0