結果

問題 No.554 recurrence formula
ユーザー fal_rndfal_rnd
提出日時 2017-08-11 22:27:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 78,784 KB
実行使用メモリ 55,912 KB
最終ジャッジ日時 2024-04-20 22:42:24
合計ジャッジ時間 5,110 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 100 ms
52,900 KB
testcase_02 AC 110 ms
54,236 KB
testcase_03 AC 111 ms
54,116 KB
testcase_04 AC 104 ms
52,488 KB
testcase_05 AC 99 ms
52,640 KB
testcase_06 AC 112 ms
53,776 KB
testcase_07 AC 112 ms
53,740 KB
testcase_08 AC 101 ms
52,568 KB
testcase_09 AC 111 ms
54,024 KB
testcase_10 AC 117 ms
53,888 KB
testcase_11 AC 116 ms
53,668 KB
testcase_12 AC 113 ms
53,860 KB
testcase_13 AC 117 ms
53,768 KB
testcase_14 AC 102 ms
52,904 KB
testcase_15 AC 115 ms
54,232 KB
testcase_16 AC 112 ms
54,372 KB
testcase_17 AC 99 ms
52,872 KB
testcase_18 AC 110 ms
53,804 KB
testcase_19 AC 124 ms
54,168 KB
testcase_20 AC 106 ms
52,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		int n=getInt(),mod=1000000007;
		long sum[]={0,1};
		for(int i=1;i<=n;++i) {
			long v=(sum[(i+1)%2]*i)%mod;
			sum[i%2]=(sum[i%2]+v)%mod;
			if(i==n)System.out.println(v);
		}
	}
}
0