結果

問題 No.980 Fibonacci Convolution Hard
コンテスト
ユーザー 37zigen
提出日時 2020-01-31 22:31:06
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 614 ms / 2,000 ms
コード長 665 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,431 ms
コンパイル使用メモリ 82,860 KB
実行使用メモリ 75,448 KB
最終ジャッジ日時 2026-04-06 06:36:18
合計ジャッジ時間 14,774 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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