結果
問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
ユーザー |
|
提出日時 | 2021-07-31 11:55:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 559 ms |
コンパイル使用メモリ | 66,688 KB |
実行使用メモリ | 54,784 KB |
最終ジャッジ日時 | 2024-09-16 09:25:07 |
合計ジャッジ時間 | 5,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 4 RE * 12 |
ソースコード
#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; }