結果

問題 No.681 Fractal Gravity Glue
ユーザー 37zigen37zigen
提出日時 2020-07-03 04:42:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-10-14 09:18:52
合計ジャッジ時間 1,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,752 KB
testcase_01 AC 14 ms
7,828 KB
testcase_02 AC 14 ms
7,848 KB
testcase_03 AC 12 ms
7,804 KB
testcase_04 AC 12 ms
7,804 KB
testcase_05 AC 12 ms
7,904 KB
testcase_06 AC 13 ms
7,840 KB
testcase_07 AC 13 ms
7,908 KB
testcase_08 AC 13 ms
7,948 KB
testcase_09 AC 13 ms
7,940 KB
testcase_10 AC 13 ms
7,840 KB
testcase_11 AC 12 ms
7,784 KB
testcase_12 AC 13 ms
7,808 KB
testcase_13 AC 13 ms
7,892 KB
testcase_14 AC 12 ms
7,772 KB
testcase_15 AC 12 ms
7,896 KB
testcase_16 AC 13 ms
7,908 KB
testcase_17 AC 12 ms
7,840 KB
testcase_18 AC 12 ms
7,920 KB
testcase_19 AC 13 ms
7,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=10**9+7

def G_mod(i,d):
    ret=i*(pow(d+1,i,MOD)-1)-(d+1)*(i*d*pow(d+1,i-1,MOD)-pow(d+1,i,MOD)+1)*pow(d,MOD-2,MOD)
    ret%=MOD
    return ret

n=int(input())
b,d=map(int,input().split())

tot=G_mod(b,d)

while n>0:
    p=0
    while pow(d+1,p+1)-1<=n:
        p+=1
    q=n//pow(d+1,p)
    tot-=q*(p+1+G_mod(p,d))
    n-=q*pow(d+1,p)
    if n==pow(d+1,p)-1:
        n-=pow(d+1,p)-1
        tot-=G_mod(p,d)
print(tot%MOD)
0