結果

問題 No.980 Fibonacci Convolution Hard
ユーザー 37zigen37zigen
提出日時 2020-01-31 22:31:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,087 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 3,039 ms
コンパイル使用メモリ 77,180 KB
実行使用メモリ 79,040 KB
最終ジャッジ日時 2023-10-17 13:39:40
合計ジャッジ時間 23,482 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,034 ms
79,040 KB
testcase_01 AC 1,087 ms
74,268 KB
testcase_02 AC 1,027 ms
76,676 KB
testcase_03 AC 1,031 ms
74,368 KB
testcase_04 AC 1,049 ms
78,928 KB
testcase_05 AC 1,036 ms
74,428 KB
testcase_06 AC 1,017 ms
79,012 KB
testcase_07 AC 1,076 ms
75,216 KB
testcase_08 AC 1,080 ms
76,196 KB
testcase_09 AC 1,050 ms
74,976 KB
testcase_10 AC 1,039 ms
75,792 KB
testcase_11 AC 1,042 ms
74,908 KB
testcase_12 AC 1,065 ms
79,020 KB
testcase_13 AC 1,024 ms
78,428 KB
testcase_14 AC 1,083 ms
76,620 KB
testcase_15 AC 1,022 ms
77,012 KB
testcase_16 AC 979 ms
74,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
import java.io.*;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long M = (long) 1e9 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		long p=sc.nextLong();
		int Q=sc.nextInt();
		int[] q=new int[Q];
		long[] b=new long[(int)2e6+1];
		b[4]=1;
		for(int i=5;i<b.length;++i)b[i]=(2*p*b[i-1]%M+(2-p*p%M)*b[i-2]%M-2*p%M*b[i-3]%M-b[i-4])%M;
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0;i<Q;++i){
			q[i]=sc.nextInt();
			pw.println((b[q[i]]+M)%M);
		}
		pw.close();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0