結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー shiomusubi496shiomusubi496
提出日時 2021-05-28 21:10:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 201,204 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-24 23:29:21
合計ジャッジ時間 4,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 31 ms
6,144 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 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 AC 109 ms
9,600 KB
testcase_23 WA -
testcase_24 AC 108 ms
9,728 KB
testcase_25 AC 158 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
using Mat=vector<vector<int>>;
constexpr int mod=1000000007;
Mat operator*(Mat a,Mat b){
    Mat c(a.size(),vector<int>(b[0].size()));
    for(int i=0;i<a.size();i++)for(int j=0;j<b[0].size();j++){
        for(int k=0;k<b.size();k++)(c[i][j]+=a[i][k]*b[k][j])%=mod;
    }
    return c;
}
Mat e(int N){
    Mat a(N,vector<int>(N));
    for(int i=0;i<N;i++)a[i][i]=1;
    return a;
}
Mat mat_pow(Mat a,int b){
    if(!b)return e(a.size());
    if(b&1)return mat_pow(a,b-1)*a;
    return mat_pow(a*a,b/2);
}
signed main(){
    int N,K,L; cin>>N>>K>>L;
    Mat A(N,vector<int>(1)),B(N,vector<int>(N));
    A[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=1;j<=L;j++)B[i][(i+j)%N]++;
    }
    Mat C=mat_pow(B,K)*A;
    for(int i=0;i<N;i++)cout<<C[i][0]<<endl;
}
0