結果
問題 |
No.3245 Payment with 8-rep Currency
|
ユーザー |
|
提出日時 | 2025-08-22 22:47:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,824 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 205,128 KB |
実行使用メモリ | 16,608 KB |
最終ジャッジ日時 | 2025-08-22 22:47:10 |
合計ジャッジ時間 | 6,293 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); vector<int> stk, S; vector<int> a = {1, 11, 111, 1111}; vector<vector<int>> ope; reverse(a.begin(), a.end()); int sv = 0; constexpr int r = 20; vector<int> S2(12); vector<vector<int>> op2(12); auto dfs = [&](auto dfs, int p, int pay) -> void { if(p == 4){ for(auto v : stk){ if(2 * v >= sv) return; } S.emplace_back(pay); ope.emplace_back(stk); // mod 12 で分類 if(S2[pay % 12] == 0){ S2[pay % 12] = pay; op2[pay % 12] = stk; } return; } for(int i = 0; i <= r; i++){ stk.emplace_back(i); sv += i; dfs(dfs, p + 1, pay + a[p] * i); sv -= i; stk.pop_back(); } }; dfs(dfs, 0, 0); int T; cin >> T; array<ll, 4> ans; while(T--){ ll n; cin >> n; ans.fill(0); if(n % 8 != 0){ cout << "-1\n"; continue; } n /= 8; if(n <= S.back()){ int p = lower_bound(S.begin(), S.end(), n) - S.begin(); if(n == S[p]){ for(int i = 0; i < 4; i++){ cout << ope[p][i] << (i == 3 ? '\n' : ' '); } }else{ cout << "-1\n"; } continue; } int mod = n % 12; for(int i = 0; i < 4; i++){ ans[i] += op2[mod][i]; } n -= S2[mod]; n /= 12; ans[0] += n; ans[1] += n; for(int i = 0; i < 4; i++) cout << ans[i] << (i == 3 ? '\n' : ' '); } }