結果
| 問題 | 
                            No.1629 Sorting Integers (SUM of M)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-07-31 05:25:47 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 851 bytes | 
| コンパイル時間 | 962 ms | 
| コンパイル使用メモリ | 94,004 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-16 09:06:22 | 
| 合計ジャッジ時間 | 1,798 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | WA * 14 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9+7;
int main()
{
    int n;
    cin >> n;
    vector<int> a;
    map<int, int> mp;
    for(int i = 0; i < 9; i++){
        cin >> mp[i+1];
        if(mp[i+1] > 0) a.push_back(i+1);
    }
    ll ans = 0, tmp = 1;
    ll num = 1;
    for(int i = a.size()-1; i >= 1; i--) num *= i;
    for(int i = 0; i < n; i++){
        //cout << "----" << tmp << "----" << endl;
        for(int j : a){
            //cout << "j: " << j << " num[j]: " << mp[j] << endl;
            ans = ans+((((j*tmp)%mod)*num)%mod)*mp[j]%mod;
            ans %= mod;
        }
        tmp *= 10;
    }
    cout << ans << endl;
    return 0;
}