結果

問題 No.997 Jumping Kangaroo
ユーザー 37zigen37zigen
提出日時 2020-02-21 23:24:06
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,443 bytes
コンパイル時間 2,363 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 59,988 KB
最終ジャッジ日時 2023-07-30 08:07:31
合計ジャッジ時間 8,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,876 KB
testcase_01 AC 127 ms
55,932 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 183 ms
56,040 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 129 ms
55,972 KB
testcase_25 WA -
testcase_26 AC 127 ms
55,816 KB
testcase_27 AC 127 ms
56,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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[][] mat=new long[2*W+1][2*W+1];
		for(int i=0;i<N;++i){
			mat[0][A[i]-1]++;
		}
		for(int i=1;i<N;++i){
			mat[i][i-1]=1;
		}
		long[][] mat2=pow_mat(pow_mat(mat,W),K);
		
		long[][] v=new long[mat.length][1];
		v[0][0]=1;
		long[][] ans=mul(mat2,v);
		System.out.println(ans[0][0]);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0