結果

問題 No.980 Fibonacci Convolution Hard
ユーザー 37zigen
提出日時 2020-01-31 22:31:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,134 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 77,920 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-09-17 11:34:48
合計ジャッジ時間 24,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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