結果
問題 | No.741 AscNumber(Easy) |
ユーザー |
|
提出日時 | 2017-03-17 22:15:02 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-07-04 13:44:13 |
合計ジャッジ時間 | 6,340 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
コンパイルメッセージ
Syntax OK
ソースコード
cin = gets.chomp! abort unless cin n = cin.to_i abort unless 1 <= n && n <= 1000000 # x^q def powm(x,q,mod=1000000007) y=1 x=x%mod while (0<q) y=(y*x)%mod if q%2==1 x=(x*x)%mod q/=2 end y end # 組み合わせの数nCk def combim(n,k,mod=1000000007) q=1 k.downto(1){|rr| q=(((q*(n-rr+1))%mod)*powm(rr,mod-2,mod))%mod } q end # 重複組み合わせの数 nHr def mcombim(n,r,mod=1000000007) combim(n-1+r,n-1,mod) end p mcombim(10,n)