結果
問題 |
No.3245 Payment with 8-rep Currency
|
ユーザー |
|
提出日時 | 2025-08-22 22:44:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,766 bytes |
コンパイル時間 | 2,005 ms |
コンパイル使用メモリ | 201,168 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-22 22:44:42 |
合計ジャッジ時間 | 8,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); long long all = 9872/8; int n = all*10; vector<tuple<int,int,int,int>> V(n); for(int v=0; v<n; v++){ int best = 1001001001; bool ok = false; for(int d=0; d*1111<=v&&ok==false; d++){ for(int c=0; c*111+d*1111<=v&&ok==false; c++){ for(int b=0; b*11+c*111+d*1111<=v&&ok==false; b++){ int a = v-d*1111-c*111-b*11; int sum = a+b+c+d,use = max({a,b,c,d}); if(use+use < sum) V.at(v) = {a,b,c,d},ok = true; else if(best > use+use-sum) best = use+use-sum,V.at(v) = {a,b,c,d}; } } } if(v){ auto [a,b,c,d] = V.at(v); assert(a+b+c+d != 0); } //if(!ok){cout << v << " " << best << endl;} } int T; cin >> T; for(long long NN=8; NN<=T; NN+=8){ cout << NN << " "; long long N = NN; if(N%8){cout << "-1\n"; continue;} N /= 8; if(N < n){ auto [a,b,c,d] = V.at(N); long long use = max({a,b,c,d}),sum = a+b+c+d; assert(a+b*11+c*111+d*1111 == N); if(use+use >= sum) cout << "-1\n"; else cout << a << " " << b << " " << c << " " << d << "\n"; } else{ long long pos = N%all,memo = N; N -= n-all+pos; auto [a,b,c,d] = V.at(pos+n-all); assert(N%all == 0); N /= all; a += N,b += N,c += N,d += N; assert(a+b*11+c*111+d*1111 == memo); cout << a << " " << b << " " << c << " " << d << "\n"; } } }