結果
| 問題 |
No.554 recurrence formula
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-11 22:32:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 789 bytes |
| コンパイル時間 | 3,140 ms |
| コンパイル使用メモリ | 74,724 KB |
| 実行使用メモリ | 56,120 KB |
| 最終ジャッジ日時 | 2024-10-12 21:14:35 |
| 合計ジャッジ時間 | 6,513 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 RE * 1 |
ソースコード
import java.io.*;
import java.util.*;
public class Main_yukicoder554 {
private static Scanner sc;
private static Printer pr;
private static void solve() {
final int MOD = 1_000_000_007;
int n = sc.nextInt();
long[] a = new long[n + 1];
long[] sum = new long[n + 1];
a[1] = 1;
sum[1] = 1;
a[2] = 2;
sum[2] = 2;
for (int i = 3; i <= n; i++) {
a[i] = sum[i - 1] * i % MOD;
sum[i] = sum[i - 2] + a[i];
sum[i] %= MOD;
}
pr.println(a[n]);
}
// ---------------------------------------------------
public static void main(String[] args) {
sc = new Scanner(System.in);
pr = new Printer(System.out);
solve();
pr.close();
sc.close();
}
private static class Printer extends PrintWriter {
Printer(PrintStream out) {
super(out);
}
}
}