Submission #6425174
Source Code Expand
using System; using System.Linq;//リストの使用 using System.Collections.Generic; using System.Text;//テキストの高速出力に必要 class Program { static void Main() { long mod = 1000000007; string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]); int k = int.Parse(input[1]); long[] dp = new long[n]; long[] sums = new long[n]; dp[0] = 1; dp[1] = 0; sums[0] = 1; sums[1] = 1; long answer = 0; for(int i = 2; i <= n-1; i++) { dp[i] = sums[i-1]; if(0 <= i-k-1) dp[i] -= sums[i-k-1]; dp[i] %= mod; if(dp[i] < 0) dp[i] += mod; sums[i] = sums[i-1] + dp[i]; sums[i] %= mod; } answer = sums[n-1]; if(0 <= n-k) answer -= sums[n-k]; answer %= mod; if(answer < 0) answer += mod; Console.WriteLine(answer); } }
Submission Info
Submission Time | |
---|---|
Task | F - 準急 |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 4 |
Code Size | 882 Byte |
Status | AC |
Exec Time | 65 ms |
Memory | 25312 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 4 / 4 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 03, 04, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 65 ms | 24416 KB |
01 | AC | 59 ms | 24416 KB |
02 | AC | 42 ms | 15968 KB |
03 | AC | 37 ms | 15968 KB |
04 | AC | 64 ms | 25312 KB |
90 | AC | 21 ms | 9044 KB |
91 | AC | 21 ms | 11092 KB |