結果

問題 No.1011 Infinite Stairs
ユーザー c-yanc-yan
提出日時 2020-06-21 09:22:25
言語 Go
(1.22.1)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 11,975 ms
コンパイル使用メモリ 216,236 KB
実行使用メモリ 7,764 KB
最終ジャッジ日時 2023-09-24 11:19:00
合計ジャッジ時間 13,822 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 56 ms
5,544 KB
testcase_04 AC 85 ms
5,540 KB
testcase_05 AC 86 ms
7,764 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 36 ms
5,528 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 20 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 59 ms
5,544 KB
testcase_17 AC 62 ms
5,532 KB
testcase_18 AC 26 ms
5,532 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 15 ms
5,528 KB
testcase_22 AC 53 ms
5,536 KB
testcase_23 AC 15 ms
4,384 KB
testcase_24 AC 14 ms
5,524 KB
testcase_25 AC 25 ms
4,380 KB
testcase_26 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func main() {
	N := readInt()
	d := readInt()
	K := readInt()

	buf0 := make([]int, d*N+K+1)
	buf1 := make([]int, d*N+K+1)
	buf0[0] = 1
	for i := 0; i < N; i++ {
		t := 0
		for j := 0; j < d; j++ {
			t += buf0[j]
			t %= m
			buf1[j] = t
		}
		for j := d; j < (i+1)*d; j++ {
			t -= buf0[j-d]
			if t < 0 {
				t += m
			}
			t += buf0[j]
			t %= m
			buf1[j] = t
		}
		buf0, buf1 = buf1, buf0
	}
	fmt.Println(buf0[K-N])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}
0