結果
問題 | No.997 Jumping Kangaroo |
ユーザー | 37zigen |
提出日時 | 2020-02-22 00:12:16 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 136 ms / 2,000 ms |
コード長 | 1,480 bytes |
コンパイル時間 | 2,653 ms |
コンパイル使用メモリ | 77,772 KB |
実行使用メモリ | 41,924 KB |
最終ジャッジ日時 | 2024-04-17 10:04:03 |
合計ジャッジ時間 | 7,101 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
41,748 KB |
testcase_01 | AC | 126 ms
41,360 KB |
testcase_02 | AC | 124 ms
41,260 KB |
testcase_03 | AC | 136 ms
41,620 KB |
testcase_04 | AC | 129 ms
41,236 KB |
testcase_05 | AC | 115 ms
41,696 KB |
testcase_06 | AC | 121 ms
41,252 KB |
testcase_07 | AC | 128 ms
41,492 KB |
testcase_08 | AC | 127 ms
41,548 KB |
testcase_09 | AC | 123 ms
41,684 KB |
testcase_10 | AC | 120 ms
40,184 KB |
testcase_11 | AC | 119 ms
40,444 KB |
testcase_12 | AC | 122 ms
41,796 KB |
testcase_13 | AC | 124 ms
41,384 KB |
testcase_14 | AC | 121 ms
41,296 KB |
testcase_15 | AC | 119 ms
41,400 KB |
testcase_16 | AC | 118 ms
40,404 KB |
testcase_17 | AC | 124 ms
41,372 KB |
testcase_18 | AC | 122 ms
41,924 KB |
testcase_19 | AC | 125 ms
41,560 KB |
testcase_20 | AC | 130 ms
41,816 KB |
testcase_21 | AC | 128 ms
41,436 KB |
testcase_22 | AC | 124 ms
40,380 KB |
testcase_23 | AC | 134 ms
41,852 KB |
testcase_24 | AC | 126 ms
41,336 KB |
testcase_25 | AC | 128 ms
41,312 KB |
testcase_26 | AC | 128 ms
41,380 KB |
testcase_27 | AC | 131 ms
41,352 KB |
ソースコード
import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; import java.math.*; class Main { public static void main(String[] args) throws Exception { new Main().run(); } long[][] mul(long[][] a,long[][] b){ long[][] ret=new long[a.length][b[0].length]; for(int i=0;i<a.length;++i){ for(int j=0;j<b[i].length;++j){ for(int k=0;k<a[i].length;++k){ ret[i][j]+=a[i][k]*b[k][j]%M; ret[i][j]%=M; } } } return ret; } long[][] pow_mat(long[][] a,long n){ long[][] ret=new long[a.length][a.length]; ret[0][0]=ret[1][1]=1; for(;n>0;n>>=1,a=mul(a,a))if(n%2==1)ret=mul(ret,a); return ret; } long pow(long a,long n){ long ret=1; for(;n>0;n>>=1,a=a*a%M)if(n%2==1)ret=ret*a%M; return ret; } long inv(long a){ return pow(a,M-2); } final long M=(long)1e9+7; void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int W=sc.nextInt(); long K=sc.nextLong(); int[] A=new int[N]; for(int i=0;i<N;++i){ A[i]=sc.nextInt(); } long[] a=new long[2*W+1]; a[0]=1; for(int i=0;i<a.length;++i){ for(int j=0;j<A.length;++j){ if(i+A[j]<a.length){ a[i+A[j]]+=a[i]; a[i+A[j]]%=M; } } } long u=a[W]; long v=a[2*W]-u*u%M; long[][] mat={{u,v},{1,0}}; mat=pow_mat(mat,K); long ans=mat[0][0]; System.out.println((ans%M+M)%M); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }