結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー asaringoasaringo
提出日時 2021-07-30 21:42:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 815 bytes
コンパイル時間 1,654 ms
コンパイル使用メモリ 170,688 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-10-14 04:00:54
合計ジャッジ時間 5,557 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,224 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 41 ms
4,348 KB
testcase_04 AC 12 ms
4,356 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 4 ms
4,352 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef pair<int,int> P ;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define chmin(a,b) a = min(a,b) ;

const int mod = 1000000007 ;

int n , k ;
vector<int> digit ;

ll powmod(ll x , ll n){
    ll res = 1 ;
    while(n > 0){
        if(n & 1) (res *= x) %= mod ;
        (x *= x) %= mod ;
        n >>= 1 ;
    }
    return res ;
}

int main(){
    cin >> n ;
    rep(i,9){
        int c ;
        cin >> c ;
        rep(j,c){
            digit.push_back(i+1) ;
        }
    }
    sort(digit.begin(),digit.end()) ;
    ll res = 0 ;
    do{
        rep(i,n) (res += digit[i] * powmod(10,i) % mod) %= mod ;
    } while (next_permutation(digit.begin(),digit.end()));
    cout << res << endl ;
}
0