結果
問題 |
No.1102 Remnants
|
ユーザー |
![]() |
提出日時 | 2020-07-03 16:06:06 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 465 ms / 2,000 ms |
コード長 | 990 bytes |
コンパイル時間 | 9,560 ms |
コンパイル使用メモリ | 188,308 KB |
実行使用メモリ | 76,032 KB |
最終ジャッジ日時 | 2024-09-16 17:07:25 |
合計ジャッジ時間 | 17,657 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (388 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
open System let R T = stdin.ReadLine()|> T let RS T = stdin.ReadLine().Split()|>Array.map T let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U) let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V) let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W) let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X) [<EntryPoint>] let main argv = let N,K = R2 int int64 let A = RS int64 let MOD = 1000000007L let rec modpow (x:int64) n = match n with | 0 -> 1L | 1 -> x%MOD | _ when n%2=0 -> ((modpow ((x*x)%MOD) (n/2)))%MOD | _ -> (x*(modpow x (n-1)))%MOD let comb = [|for i in [1..N] do yield 1L|] for i in [1..(N-1)] do comb.[i] <- ((comb.[i-1]*(K+(i|>int64)))%MOD*(modpow (i|>int64) 1000000005))%MOD [for i in [0..(N-1)] do yield ((comb.[i]*comb.[N-1-i])%MOD*A.[i])%MOD] |>List.reduce (fun a b -> (a+b)%MOD) |>stdout.WriteLine 0