結果

問題 No.681 Fractal Gravity Glue
ユーザー cielciel
提出日時 2018-04-28 18:15:28
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,580 KB
実行使用メモリ 16,392 KB
最終ジャッジ日時 2023-09-10 07:52:21
合計ジャッジ時間 2,792 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,144 KB
testcase_01 AC 84 ms
15,064 KB
testcase_02 AC 83 ms
15,152 KB
testcase_03 AC 82 ms
15,060 KB
testcase_04 AC 87 ms
16,344 KB
testcase_05 AC 83 ms
15,800 KB
testcase_06 AC 84 ms
15,880 KB
testcase_07 AC 88 ms
16,392 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 83 ms
15,144 KB
testcase_18 AC 84 ms
15,200 KB
testcase_19 AC 83 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
Mod=10**9+7
def count(i,d)
	(d+1).pow(i)-1
end

def sum(i,d)
	((d+1)*((d+1).pow(i)-1)%Mod*d.pow(Mod-2,Mod)%Mod-i+Mod)%Mod
end
def sum_n(i,d,n)
	return 0 if n==0
	s=count(i-1,d)
	t=n/(1+s)
	(t*(i+sum(i-1,d))%Mod+sum_n(i-1,d,n-t*(1+s)))%Mod
end
n,b,d=`dd`.split.map &:to_i
i=1
loop{
	if count(i,d)>n
		p (sum(b,d)+Mod-sum_n(i,d,n))%Mod
		exit
	end
	i+=1
}
0