結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー the-xinthe-xin
提出日時 2021-07-31 11:55:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 67,600 KB
実行使用メモリ 54,664 KB
最終ジャッジ日時 2023-10-14 14:50:14
合計ジャッジ時間 16,989 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,996 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 16 ms
54,580 KB
testcase_27 WA -
testcase_28 AC 146 ms
54,664 KB
testcase_29 AC 140 ms
54,648 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1<<14;
LL f[N][400];
int cnt[12];
int a[N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	LL ttt=1,tot=0;
	for(int i=1;i<=9;i++){
		scanf("%d",&cnt[i]);
		LL tt=1;
		for(int j=1;j<=cnt[i];j++){
			tt=tt*j;
			a[++tot]=i;
		}
		ttt=tt*ttt;
	}
	f[0][0]=1;
	for(int i=0;i<(1<<n)-1;i++){
		for(int j=0;j<m;j++){
			if(!f[i][j])continue;
			for(int k=0;k<n;k++){
				if(i>>k&1)continue;
				int t=j*10+a[k+1];
				t%=m;
				f[i|(1<<k)][t]+=f[i][j];
			}
		}
	}
	cout<<f[(1<<n)-1][0]/ttt;
	return 0;
}
0