結果

問題 No.3245 Payment with 8-rep Currency
ユーザー ゼット
提出日時 2025-08-24 00:42:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 77,764 KB
最終ジャッジ日時 2025-08-24 00:42:27
合計ジャッジ時間 15,124 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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(22):
    if x>=0:
      break
    if 111*a>N:
      break
    for b in range(222):
      if 111*a+11*b>N:
        break
      z2=a
      y2=b
      x2=N-(111*a+11*b)
      S=(x2+y2+z2)//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)
0