結果

問題 No.1102 Remnants
コンテスト
ユーザー eSeF
提出日時 2020-07-03 16:06:06
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 990 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,967 ms
コンパイル使用メモリ 209,644 KB
実行使用メモリ 81,512 KB
最終ジャッジ日時 2026-04-05 21:53:18
合計ジャッジ時間 12,462 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (729 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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
0