結果
| 問題 |
No.194 フィボナッチ数列の理解(1)
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-05-01 09:49:49 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,389 bytes |
| コンパイル時間 | 924 ms |
| コンパイル使用メモリ | 114,156 KB |
| 実行使用メモリ | 29,044 KB |
| 最終ジャッジ日時 | 2024-09-14 01:49:06 |
| 合計ジャッジ時間 | 3,406 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 10 WA * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
new Magatro().Solve();
}
}
class Magatro
{
private int N;
private long K;
private int[] A;
private const int Mod = (int)1e9 + 7;
private void Scan()
{
string[] s = Console.ReadLine().Split(' ');
N = int.Parse(s[0]);
K = long.Parse(s[1]);
A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public void Solve()
{
Scan();
if (K <= 1000000)
{
Easy();
}
else
{
Hard();
}
}
private void Easy()
{
int s = 0;
int sum = 0;
var dp = new int[K + 1];
for(int i = 0; i < N; i++)
{
dp[i + 1] = A[i];
sum += A[i];
}
sum %= Mod;
for (int i = N + 1; i <= K; i++)
{
dp[i] = sum;
sum *= 2;
sum -= dp[i - N];
while (sum < 0)
{
sum += Mod;
}
sum %= Mod;
}
foreach(var i in dp)
{
s += i;
s %= Mod;
}
Console.WriteLine($"{dp[K]} {s}");
}
private void Hard()
{
}
}
mban