結果
問題 |
No.3245 Payment with 8-rep Currency
|
ユーザー |
![]() |
提出日時 | 2025-08-28 08:28:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,314 bytes |
コンパイル時間 | 721 ms |
コンパイル使用メモリ | 69,748 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-28 08:29:02 |
合計ジャッジ時間 | 6,641 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 WA * 12 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; struct S { ll a,b,c,d; }; void pri(S s){ cout << s.a << " " << s.b << " " << s.c << " " << s.d << "\n"; } const int B = 3000; S ans[B + 10]; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int i,t; cin >> t; for(i=0;i<=B;i++) ans[i] = {-1,-1,-1,-1}; for(int a=0;a*1<=B;a++){ for(int b=0;a + b*11<=B;b++){ for(int c=0;a + b*11 + c*111<=B;c++){ for(int d=0;a + b*11 + c*111 + d*1111<=B;d++){ int sum = a + b + c + d; if(2*a<sum && 2*b<sum && 2*c<sum && 2*d<sum){ ans[a + b*11 + c*111 + d*1111] = {a,b,c,d}; } } } } } while(t){ t--; ll n; cin >> n; if(n%8){ cout << -1 << "\n"; continue; } n /= 8; if(n<=B){ if(ans[n].a==-1) cout << -1 << "\n"; else pri(ans[n]); }else{ int a = 0,b = 0,c = 0,d = 0; while(n%3){ d++; n -= 1111; } while(c==0 || n%12){ c++; n -= 111; } a = b = n/12; pri({a,b,c,d}); } } }