結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー logxlogx
提出日時 2021-07-30 22:48:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,377 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 204,072 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-14 07:13:09
合計ジャッジ時間 5,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint=atcoder::modint1000000007;
//using namespace atcoder;

/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)

/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
    constexpr operator int(){return -int(1e9)-10;}
    constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
    constexpr operator int(){return int(1e9)+10;}
    constexpr operator ll(){return ll(1e18)+10;}
    constexpr auto operator -(){return neginf;}
}inf;

/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif

/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}

using dmint=atcoder::modint;

int main(){
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    std::cout.precision(10);
/*------------------------------------*/
    
    int n;
    cin >> n;
    int cnt[10];
    int types=0;
    rep(i,9)cin >> cnt[i+1],types+=(cnt[i+1]!=0);
    if(types==1){
        mint ans=(mint(10).pow(n)-1)/9;
        rep(i,9)if(cnt[i+1])ans*=i+1;
        cout << ans.val() << newl;
        return 0;
    }
    int ans=1;
    {
        bool all2=true,all4=true;
        rep2(i,1,10)if(cnt[i]){
            if(i%2!=0)all2=false;
            if(i%4!=0)all4=false;
        }
        if(all4)ans*=4;
        else if(all2)ans*=2;
    }
    {
        int sum=0;
        rep(i,9)sum+=cnt[i+1]%9 * (i+1);
        sum%=9;
        if(sum==0)ans*=9;
        else if(sum%3==0)ans*=3;
        //27の倍数か否か?
        if(sum==0){
            dmint::set_mod(27);
            dmint x=0;//適当に並べた時にmod27で零か?
            vector<int> vec;
            rep(i,9){
                int val=111*(i+1);
                x+=val*(cnt[i+1]/3);
                rep(j,cnt[i+1]%3)vec.emplace_back(i+1);
            }
            until(vec.size()%3==0)vec.emplace_back(0);
            rep(i,vec.size()/3){
                x+=vec[3*i] + 10*vec[3*i+1] + 100*vec[3*i+2];
            }
            if(x.val()==0)ans*=3;
        }
    }
    cout << ans << newl;
}
0