結果
問題 |
No.554 recurrence formula
|
ユーザー |
![]() |
提出日時 | 2018-09-11 13:04:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 2,380 ms |
コンパイル使用メモリ | 103,808 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-06-23 06:45:54 |
合計ジャッジ時間 | 3,779 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { public const int MOD = 1000000007; public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); if (n == 1) { Console.WriteLine(1); goto end; } var b1 = 0L; var b2 = 0L; var pre = 1L; for (int i = 2; i <= n; i++) { if (i % 2 == 0) { var w = (i * (pre + b2)) % MOD; b2 += pre; b2 %= MOD; pre = w; } else { var w = (i * (pre + b1)) % MOD; b1 += pre; b1 %= MOD; pre = w; } } Console.WriteLine(pre); end:; } }