結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー mugen_1337mugen_1337
提出日時 2021-07-08 15:23:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 803 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 204,816 KB
実行使用メモリ 132,028 KB
最終ジャッジ日時 2023-10-14 02:09:22
合計ジャッジ時間 21,173 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 95 ms
131,768 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 473 ms
131,660 KB
testcase_15 AC 487 ms
131,584 KB
testcase_16 AC 486 ms
131,812 KB
testcase_17 AC 488 ms
131,544 KB
testcase_18 AC 488 ms
131,568 KB
testcase_19 AC 491 ms
131,572 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 97 ms
131,536 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

vector<vector<ll>> dp(1<<14, vector<ll>(1001, 0));

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> cnt(10, 0), A;
	for(int i = 1; i < 10; i++){
	    cin >> cnt[i];
	    for(int j = 0; j < cnt[i]; j++) A.push_back(i);
	}
	
	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++){
	               dp[cur | (1<<i)][(j * 10 + A[i]) % K] += dp[cur][j];
	           }
	       }
	   }
	}
	ll res = dp[(1<<N) - 1][0];
	for(int i = 1; i < 10; i++) res /= cnt[i];    
	cout << res << endl;
	return 0;
}
0