結果
問題 |
No.978 Fibonacci Convolution Easy
|
ユーザー |
|
提出日時 | 2020-01-31 22:00:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 232 ms / 2,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 2,260 ms |
コンパイル使用メモリ | 78,140 KB |
実行使用メモリ | 90,032 KB |
最終ジャッジ日時 | 2024-09-18 20:58:31 |
合計ジャッジ時間 | 7,510 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import java.util.*; import java.io.*; // This file is a "Hello, world!" in Java language by OpenJDK for wandbox. class Main { public static void main(String[] args) { new Main().run(); } final long m=(long)1e9+7; void run(){ Scanner sc=new Scanner(System.in); int N=sc.nextInt(); long p=sc.nextLong(); long[] a=new long[(int)(3e6)]; long[] s=new long[(int)(3e6)]; a[1]=0; a[2]=1; for(int i=3;i<a.length;++i)a[i]=(p*a[i-1]%m+a[i-2])%m; for(int i=1;i<a.length;++i)s[i]=(s[i-1]+a[i])%m; long ans=0; for(int i=1;i<=N;++i){ ans=(ans+s[i]*a[i]%m)%m; } System.out.println(ans); } void tr(Object...o){System.out.println(Arrays.deepToString(o));} } // OpenJDK reference: // http://openjdk.java.net/ // Java language references: // http://docs.oracle.com/javase