結果

問題 No.980 Fibonacci Convolution Hard
ユーザー 37zigen37zigen
提出日時 2020-01-31 22:35:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,102 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 2,349 ms
コンパイル使用メモリ 77,536 KB
実行使用メモリ 89,300 KB
最終ジャッジ日時 2023-10-17 13:42:53
合計ジャッジ時間 24,039 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,094 ms
89,300 KB
testcase_01 AC 1,083 ms
88,932 KB
testcase_02 AC 1,070 ms
76,536 KB
testcase_03 AC 1,065 ms
87,880 KB
testcase_04 AC 1,077 ms
77,616 KB
testcase_05 AC 1,070 ms
87,672 KB
testcase_06 AC 1,067 ms
88,436 KB
testcase_07 AC 1,102 ms
88,216 KB
testcase_08 AC 1,069 ms
75,592 KB
testcase_09 AC 1,073 ms
87,736 KB
testcase_10 AC 1,098 ms
76,168 KB
testcase_11 AC 1,079 ms
86,496 KB
testcase_12 AC 1,088 ms
76,004 KB
testcase_13 AC 1,050 ms
88,540 KB
testcase_14 AC 1,036 ms
88,624 KB
testcase_15 AC 1,063 ms
88,544 KB
testcase_16 AC 1,011 ms
78,524 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();
	}
}
0