結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
19,668 KB
testcase_01 AC 80 ms
15,092 KB
testcase_02 AC 83 ms
15,204 KB
testcase_03 AC 81 ms
15,084 KB
testcase_04 AC 81 ms
15,304 KB
testcase_05 AC 79 ms
15,056 KB
testcase_06 AC 78 ms
15,052 KB
testcase_07 AC 78 ms
15,312 KB
testcase_08 WA -
testcase_09 AC 79 ms
15,144 KB
testcase_10 AC 78 ms
15,304 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

Mod=10**9+7
def count(i,d)
	(d+1).pow(i,Mod)-1
end

def sum(i,d)
	((d+1)*((d+1).pow(i,Mod)-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