結果
| 問題 | No.554 recurrence formula |
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2018-09-24 20:37:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 138 ms / 2,000 ms |
| コード長 | 461 bytes |
| コンパイル時間 | 3,109 ms |
| コンパイル使用メモリ | 74,244 KB |
| 実行使用メモリ | 54,320 KB |
| 最終ジャッジ日時 | 2024-09-23 05:13:32 |
| 合計ジャッジ時間 | 6,281 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
scan.close();
long d = 1000000000 + 7;
long s1 = 1;
long s2 = 0;
long a = 1;
for(int i = 2; i <= n; i++) {
if(i % 2 == 0) {
a = i * s1 % d;
s2 += a % d;
}else {
a = i * s2 % d;
s1 += a % d;
//System.out.println(s2);
}
}
a = a % d;
System.out.println(a);
}
}
YamaKasa