結果
問題 | No.2593 Reorder and Mod 120 |
ユーザー |
|
提出日時 | 2023-12-22 00:16:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 860 ms |
コンパイル使用メモリ | 88,056 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 11:15:27 |
合計ジャッジ時間 | 1,848 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
#include <iostream> #include <numeric> #include <algorithm> using namespace std; constexpr int Z = 40; void dfs(int cnt[10], int n, int a, bool f[]) { if (n == 0) { f[a%Z] = true; return; } for (int i = 0; i < 10; i++) { if (cnt[i] > 0) { cnt[i]--; dfs(cnt, n - 1, a * 10 + i, f); cnt[i]++; } } } int main() { int n; cin >> n; int cnt[10] = {0}; for (int i = 0; i < n; i++) { char c; cin >> c; cnt[c-'0']++; } for (int i = 0; i < 10; i++) { cnt[i] = min(cnt[i], 3); } bool f[Z] = {false}; dfs(cnt, min(3, n), 0, f); cout << accumulate(f, f + Z, 0) << endl; return 0; }