結果
| 問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 20:51:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 548 ms / 3,000 ms |
| コード長 | 411 bytes |
| コンパイル時間 | 546 ms |
| コンパイル使用メモリ | 67,320 KB |
| 実行使用メモリ | 130,816 KB |
| 最終ジャッジ日時 | 2024-09-15 22:42:24 |
| 合計ジャッジ時間 | 7,684 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
int c[14];
long dp[1<<14][1000];
main()
{
cin>>N>>K;
int sz=0;
long v=1;
for(int i=1;i<=9;i++)
{
int C;cin>>C;
for(;C;v*=C--)c[sz++]=i;
}
dp[0][0]=1;
for(int i=0;i<1<<N;i++)for(int j=0;j<K;j++)if(dp[i][j])
{
for(int k=0;k<N;k++)if(!(i>>k&1))
{
dp[i|1<<k][(j*10+c[k])%K]+=dp[i][j];
}
}
cout<<dp[(1<<N)-1][0]/v<<endl;
}