結果

問題 No.129 お年玉(2)
ユーザー fmhrfmhr
提出日時 2015-04-23 07:20:42
言語 Go
(1.22.1)
結果
MLE  
実行時間 -
コード長 1,126 bytes
コンパイル時間 11,087 ms
コンパイル使用メモリ 227,348 KB
実行使用メモリ 805,260 KB
最終ジャッジ日時 2024-04-18 10:39:50
合計ジャッジ時間 45,066 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
42,240 KB
testcase_01 MLE -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 598 ms
334,976 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 AC 794 ms
444,544 KB
testcase_09 MLE -
testcase_10 MLE -
testcase_11 AC 764 ms
435,200 KB
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 AC 822 ms
453,888 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 AC 808 ms
447,104 KB
testcase_23 MLE -
testcase_24 MLE -
testcase_25 AC 766 ms
436,608 KB
testcase_26 AC 793 ms
441,984 KB
testcase_27 AC 765 ms
435,072 KB
testcase_28 MLE -
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 11 ms
6,528 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 9 ms
6,144 KB
testcase_36 AC 11 ms
6,912 KB
testcase_37 AC 14 ms
9,088 KB
testcase_38 AC 151 ms
89,472 KB
testcase_39 AC 245 ms
133,248 KB
testcase_40 AC 697 ms
393,088 KB
testcase_41 AC 431 ms
240,896 KB
testcase_42 AC 177 ms
100,120 KB
testcase_43 AC 177 ms
99,328 KB
testcase_44 MLE -
testcase_45 AC 101 ms
53,376 KB
testcase_46 AC 282 ms
158,336 KB
testcase_47 MLE -
testcase_48 AC 839 ms
457,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
    "fmt"
)


func pascal( n, m , mod int64) int64 {
    n += 1
    var p [10001][10001]int64
    p[0][0] = 1
    var i, j int64
    for i=1; i<n; i++ {
        for j=0; j<n; j++ {
            if j == 0 {
                p[i][j] = 1
            } else {
                p[i][j] = (p[i-1][j-1]+p[i-1][j])%mod
            }
        }
    }
    return p[n-1][m]
}

func pascal_s( n, m , mod int64) int64 {
    n += 1
    p := make([][]int64, n)
    for q:=0; q<int(n); q++ {
        p[q] = make([]int64, int(n))
    }

    p[0][0] = 1
    var i, j int64
    for i=1; i<n; i++ {
        for j=0; j<n; j++ {
            if j == 0 {
                p[i][j] = 1
            } else {
                p[i][j] = (p[i-1][j-1]+p[i-1][j])%mod
            }
        }
    }
    return p[n-1][m]
}

func main() {
    var mod int64
    mod = 1000000000
    var N, M int64
    fmt.Scan(&N)
    fmt.Scan(&M)
    var a, b, c int64
    a = N/1000/M
    b = N - (a * M) * 1000
    c = b/1000
    N /= 1000
    N %= M
//    fmt.Println(M, c)
//    fmt.Println(pascal(M, c, mod)%mod)
    fmt.Println(pascal_s(M, c, mod)%mod)
}
0