結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2017-08-11 22:58:39 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 967 ms |
コンパイル使用メモリ | 108,744 KB |
実行使用メモリ | 22,784 KB |
最終ジャッジ日時 | 2024-10-12 21:39:22 |
合計ジャッジ時間 | 10,754 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Collections.Generic; using System.Linq; class Solution { static Dictionary<int, long> dict = new Dictionary<int, long>() { { 1, 1 } }; static long F(int n) { if (dict.ContainsKey(n)) { return dict[n]; } long v = 0; for (int i = n % 2 + 1; i <= n - 1; i += 2) { v += F(i); v %= 1_000_000_000 + 7; } v *= n; v %= 1_000_000_000 + 7; dict[n] = v; return v; } static void Main() { var n = int.Parse(Console.ReadLine()); Console.WriteLine(F(n)); } }