結果
問題 |
No.3245 Payment with 8-rep Currency
|
ユーザー |
![]() |
提出日時 | 2025-08-24 00:44:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 403 ms |
コンパイル使用メモリ | 82,664 KB |
実行使用メモリ | 78,476 KB |
最終ジャッジ日時 | 2025-08-24 00:44:19 |
合計ジャッジ時間 | 15,347 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
Q=int(input()) for _ in range(Q): N=int(input()) if N%8!=0: print(-1) continue N//=8 if N>2460: x,y,z,w=N//123,N//123,N//123,0 rest=N-123*(N//123) z+=rest//111 rest-=111*(rest//111) y+=rest//11 rest-=11*(rest//11) x+=rest print(x,y,z,w) continue x,y,z,w=-1,-1,-1,-1 for a in range(50): if x>=0: break if 111*a>N: break for b in range(5000): if 111*a+11*b>N: break z2=a y2=b x2=N-(111*a+11*b) S=(x2+y2+z2-1)//2 if x2<=S and y2<=S and z2<=S: x,y,z,w=x2,y2,z2,0 break if x>=0: print(x,y,z,w) else: print(-1)