結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー |
|
提出日時 | 2021-07-30 21:39:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,603 bytes |
コンパイル時間 | 1,770 ms |
コンパイル使用メモリ | 127,592 KB |
最終ジャッジ日時 | 2025-01-23 11:23:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 TLE * 11 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <cmath>#include <queue>#include <string>#include <map>#include <set>#include <stack>#include <tuple>#include <deque>#include <array>#include <numeric>#include <bitset>#include <iomanip>#include <cassert>#include <chrono>#include <random>#include <limits>#include <iterator>#include <functional>#include <sstream>#include <fstream>#include <complex>#include <cstring>#include <unordered_map>#include <unordered_set>using namespace std;// #pragma GCC optimize("O3")// #pragma GCC optimize("unroll-loops")// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")// #pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")using ll = long long;constexpr int INF = 1001001001;constexpr int mod = 1000000007;// constexpr int mod = 998244353;template<class T>inline bool chmax(T& x, T y){if(x < y){x = y;return true;}return false;}template<class T>inline bool chmin(T& x, T y){if(x > y){x = y;return true;}return false;}int n, k;int cnt[10];ll ans = 0;void dfs(int dig = 0, int m = 0){if(dig == n){ans += m == 0;return;}for(int i = 1; i <= 9; ++i){if(cnt[i] == 0) continue;cnt[i] -= 1;dfs(dig + 1, (m * 10 + i) % k);cnt[i] += 1;}}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cin >> n >> k;for(int i = 1; i <= 9; ++i) cin >> cnt[i];dfs();cout << ans << endl;return 0;}