結果
| 問題 |
No.1629 Sorting Integers (SUM of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 21:42:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 815 bytes |
| コンパイル時間 | 1,693 ms |
| コンパイル使用メモリ | 172,040 KB |
| 実行使用メモリ | 10,660 KB |
| 最終ジャッジ日時 | 2024-09-15 23:30:58 |
| 合計ジャッジ時間 | 5,332 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 TLE * 1 -- * 10 |
ソースコード
#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 ;
}