結果
問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
ユーザー |
|
提出日時 | 2021-08-02 17:07:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 485 bytes |
コンパイル時間 | 1,614 ms |
コンパイル使用メモリ | 167,056 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-16 14:40:05 |
合計ジャッジ時間 | 6,164 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 TLE * 1 -- * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n, k; vector<int> c; long long ans = 0; void solve(int pos, vector<int> &count, int r) { if (pos == n) { if (r == 0) ans += 1; return; } for (int i = 1; i <= 9; i++) { if (count[i] > 0) { count[i] -= 1; solve(pos + 1, count, (r * 10 + i) % k); count[i] += 1; } } } int main() { cin >> n >> k; c = vector<int> (10, 0); for (int i = 1; i <= 9; i++) { cin >> c[i]; } solve(0, c, 0); cout << ans; }