結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー だれだれ
提出日時 2021-07-30 22:09:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,368 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 184,396 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-14 05:01:29
合計ジャッジ時間 6,015 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_set>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

using mint = modint1000000007;
const i64 mod = 1000000007;

i64 mypow(i64 a, i64 b){
    i64 res = 1;
    while (b){
        if (b & 1){
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> c(9);
    cin >> c;
    int f = 0;
    rep(i, 9){
        f += (c[i] > 0? 1: 0);
    }
    vector<mint> dp(35);
    dp[0] = 1;
    rep(i, 34){
        dp[i + 1] = dp[i] * pow_mod(10, mypow(2, i), mod) + dp[i];
    }
    if (f == 1){
        mint ans = 0;
        rep(i, 9){
            if (c[i] > 0){
                vector<int> h;
                rep(j, 31){
                    if ((c[i] >> j) & 1){
                        h.push_back(j);
                    }
                }
                reverse(all(h));
                for (auto j: h){
                    ans += dp[j] * pow_mod(10, c[i] - (1 << j), mod);
                    c[i] -= 1 << j;
                }
                ans *= i + 1;
                cout << ans.val() << endl;
                return 0;
            }
        }
    }
    i64 d = 0;
    int odd = 0;
    int nfour = 0;
    rep(i, 9){
        d += i64(i + 1) * c[i];
        if (((i + 1) & 1) && c[i]) odd = 1;
        if (c[i] && ((i + 1) % 4)) nfour = 1;
    }
    if (d % 9 == 0){
        if (nfour == 0){
            cout << 36 << endl;
            return 0;
        }
        else if (odd == 0){
            cout << 18 << endl;
            return 0;
        }
    }
    if (d % 3 == 0){
        if (nfour == 0){
            cout << 12 << endl;
            return 0;
        }
        if (d % 9 == 0){
            cout << 9 << endl;
            return 0;
        }
        if (odd == 0){
            cout << 6 << endl;
            return 0;
        }
    }
    if (nfour == 0) return cout << 4 << endl, 0;
    if (odd == 0) return cout << 2 << endl, 0;
    cout << 1 << endl;
}
0