結果

問題 No.2787 グッドスタイン数列?
ユーザー googol_S0googol_S0
提出日時 2023-09-29 03:18:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 53,908 KB
最終ジャッジ日時 2024-06-14 20:50:28
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,672 KB
testcase_01 AC 39 ms
52,340 KB
testcase_02 AC 38 ms
52,736 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 39 ms
53,544 KB
testcase_05 AC 39 ms
53,712 KB
testcase_06 AC 38 ms
53,280 KB
testcase_07 AC 39 ms
52,936 KB
testcase_08 AC 39 ms
52,120 KB
testcase_09 AC 38 ms
52,480 KB
testcase_10 AC 39 ms
52,756 KB
testcase_11 AC 37 ms
52,576 KB
testcase_12 AC 38 ms
53,072 KB
testcase_13 AC 38 ms
52,420 KB
testcase_14 AC 38 ms
52,272 KB
testcase_15 AC 38 ms
52,520 KB
testcase_16 AC 38 ms
52,932 KB
testcase_17 AC 38 ms
52,280 KB
testcase_18 AC 38 ms
52,344 KB
testcase_19 AC 38 ms
52,304 KB
testcase_20 AC 38 ms
53,908 KB
testcase_21 AC 38 ms
53,692 KB
testcase_22 AC 38 ms
52,004 KB
testcase_23 AC 38 ms
52,364 KB
testcase_24 AC 38 ms
52,900 KB
testcase_25 AC 37 ms
52,768 KB
testcase_26 AC 38 ms
52,848 KB
testcase_27 AC 38 ms
52,768 KB
testcase_28 AC 38 ms
53,232 KB
testcase_29 AC 37 ms
52,624 KB
testcase_30 AC 39 ms
53,568 KB
testcase_31 AC 38 ms
53,488 KB
testcase_32 AC 38 ms
53,160 KB
testcase_33 AC 38 ms
53,416 KB
testcase_34 AC 39 ms
52,472 KB
testcase_35 AC 38 ms
52,640 KB
testcase_36 AC 38 ms
52,672 KB
testcase_37 AC 38 ms
53,764 KB
testcase_38 AC 38 ms
52,868 KB
testcase_39 AC 38 ms
51,880 KB
testcase_40 AC 38 ms
53,292 KB
testcase_41 AC 38 ms
52,012 KB
testcase_42 AC 39 ms
53,440 KB
testcase_43 AC 39 ms
52,568 KB
testcase_44 AC 38 ms
53,580 KB
testcase_45 AC 38 ms
52,636 KB
testcase_46 AC 38 ms
53,424 KB
testcase_47 AC 39 ms
52,636 KB
testcase_48 AC 40 ms
52,400 KB
testcase_49 AC 39 ms
52,236 KB
testcase_50 AC 38 ms
52,476 KB
testcase_51 AC 38 ms
52,852 KB
testcase_52 AC 38 ms
52,472 KB
testcase_53 AC 38 ms
52,876 KB
testcase_54 AC 38 ms
53,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,B,M=map(int,input().split())
assert(0<=N)
assert(N<=10**18)
assert(0<=M)
assert(M<=10**18)
assert(2<=B)
assert(B<=10**18)
print('Yes')
X=[]
while N>0:
  X.append(N%B)
  N//=B
if len(X)==0:
  if 2<=M:
    print('Yes')
    print(2)
  else:
    print('No')
  exit()
B+=X[0]
ANS=X[0]*2
X[0]=0
X.append(0)
while 1:
  if X[1]>=70 or ANS>M:
    print('No')
    exit()
  if max(X)==0:
    ANS+=2
    break
  for i in range(1,len(X)):
    if X[i]>0:
      X[i]-=1
      B+=1
      ANS+=2
      for j in range(i):
        X[j]=B-1
      break
  B+=X[0]
  ANS+=X[0]*2
  X[0]=0
if ANS<=M:
  print('Yes')
  print(ANS)
else:
  print('No')
0