結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー mugen_1337mugen_1337
提出日時 2021-07-08 15:09:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 931 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 208,680 KB
実行使用メモリ 131,320 KB
最終ジャッジ日時 2023-10-14 02:07:33
合計ジャッジ時間 16,409 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 3 ms
4,352 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 758 ms
125,276 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 793 ms
131,084 KB
testcase_21 AC 697 ms
115,608 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 784 ms
128,972 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;

signed main(){
    vector<ll> fac(17, 1);
    for(int i = 2; i < 17; i++) fac[i] = fac[i - 1] * i;
    
    int N, K;
    cin >> N >> K;
    vector<int> C(N, 0), A;
    for(int i = 1; i < 10; i++){
        cin >> C[i];
        for(int j = 0; j < C[i]; j++) A.push_back(i);
    }
    
    
    vector<vector<ll>> dp(1<<N, vector<ll>(K, 0));
    dp[0][0] = 1;
    
    for(int cur = 0; cur < (1<<N); cur++){
        for(int i = 0; i < N; i++){
            if(!((cur>>i) & 1)){
                for(int j = 0; j < K; j++){
                    int nj = (j * 10 % K + A[i]) % K;
                    dp[cur | (1<<i)][nj] += dp[cur][j];
                }
            }
        }
    }
    cout << dp[(1<<N) - 1][0] << endl;
    return 0;
}
0