結果
| 問題 | No.554 recurrence formula |
| コンテスト | |
| ユーザー |
ebicochineal
|
| 提出日時 | 2017-08-11 23:17:18 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 803 bytes |
| 記録 | |
| コンパイル時間 | 794 ms |
| コンパイル使用メモリ | 112,188 KB |
| 実行使用メモリ | 30,672 KB |
| 最終ジャッジ日時 | 2024-10-12 21:50:52 |
| 合計ジャッジ時間 | 10,344 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 TLE * 1 -- * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
public class Program {
static int MOD = 1000000007;
static Dictionary<int, long> memo = new Dictionary<int, long>() { {1, 1} };
static long f (int n) {
if (memo.ContainsKey(n)) { return memo[n]; }
long s = 0;
for (int i = 1; i < n; ++i) {
if (n % 2 == 0 && i % 2 == 1) {
s = (s + f(i)) % MOD;
} else if (n % 2 == 1 && i % 2 == 0) {
s = (s + f(i)) % MOD;
}
}
memo.Add(n, (s * n) % MOD);
return memo[n];
}
static void Main (string[] args) {
int N = int.Parse(Console.ReadLine());
Console.WriteLine(f(N));
}
}
ebicochineal