結果
問題 |
No.1783 Remix Sum
|
ユーザー |
|
提出日時 | 2021-10-22 23:38:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,111 bytes |
コンパイル時間 | 1,109 ms |
コンパイル使用メモリ | 91,896 KB |
最終ジャッジ日時 | 2025-01-25 04:29:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 2 |
other | WA * 15 RE * 61 |
ソースコード
#include <cassert> #include <iostream> #include <vector> #include <cmath> using namespace std; long long ten[] = {1, 10, 100, 1000, 10000, 100000, 1000000}; long long TEN(int n) { return ten[n]; } int main() { long long n, k, m, t; cin >> n >> k >> m >> t; // assert(10 <= m and m <= 15); vector<int> a(n); for (auto& x : a) { cin >> x; // assert(0 <= x and x < TEN(k)); } if(log(n) * m > 8) exit(1); auto sm = [&](int i, int j) { int res = 0; for (int d = 0; d < k; d++) { if (d < t) { if (i % 10 + j % 10 >= 10) return -1; res += (i + j) % 10 * TEN(d); } else { res += (i + j) % 10 * TEN(d); } i /= 10, j /= 10; } return res; }; vector<long long> ans(TEN(k)); auto dfs = [&](auto rc, int depth, int s) -> void { // cerr<<depth<<" "<<s<<endl; if (s == -1) return; if (depth == m) { ans[s]++; return; } for (int i = 0; i < n; i++) rc(rc, depth + 1, sm(s, a[i])); }; dfs(dfs, 0, 0); for (int i = 0; i < TEN(k); i++) if (ans[i] != 0) cout << i << " " << ans[i] << endl; }