답안 #71719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71719 2018-08-25T13:22:35 Z 퍼솔 가즈아ㅏㅏㅏ(#2222, 16silver) 십자가 놓기 (FXCUP3_cross) C++14
100 / 100
4 ms 900 KB
#include <cstdio>
typedef struct{
    long long M[9][9];
} mat;
mat A;
long long X[9][9]={1,0,0,0,1,0,1,1,0, 1,0,0,0,0,0,1,1,0, 1,0,0,0,1,0,0,1,0, 1,0,0,0,1,0,1,0,0, 0,1,0,0,0,0,0,0,1, 0,1,0,0,0,0,0,0,0, 0,0,1,0,0,0,0,0,0, 0,0,0,1,0,1,0,0,0, 0,0,0,1,0,0,0,0,0};
mat matmul(mat x, mat y){
    mat ret;
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            ret.M[i][j]=0LL;
        }
    }
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            for(int k=0;k<9;k++){
                ret.M[i][k]=(ret.M[i][k]+x.M[i][j]*y.M[j][k])%1000000007LL;
            }
        }
    }
    return ret;
}
mat matpow(mat x, int p){
    if(p==1) return x;
    mat h=matpow(x,p/2);
    if(p&1) return matmul(matmul(h,h),x);
    return matmul(h,h);
}
mat ans;
long long pans=0LL;
int main(){
    int N;
    scanf("%d",&N);
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            A.M[i][j]=X[i][j];
        }
    }
    ans=matpow(A,N-2);
    for(int i=0;i<9;i++) pans=(pans+ans.M[i][0])%1000000007LL;
    printf("%lld",pans);
}

Compilation message

cross.cpp: In function 'int main()':
cross.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 3 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 3 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 3 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 3 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 3 ms 660 KB Output is correct
12 Correct 3 ms 864 KB Output is correct
13 Correct 2 ms 864 KB Output is correct
14 Correct 3 ms 864 KB Output is correct
15 Correct 4 ms 864 KB Output is correct
16 Correct 2 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 3 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 3 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 3 ms 660 KB Output is correct
12 Correct 3 ms 864 KB Output is correct
13 Correct 2 ms 864 KB Output is correct
14 Correct 3 ms 864 KB Output is correct
15 Correct 4 ms 864 KB Output is correct
16 Correct 2 ms 864 KB Output is correct
17 Correct 2 ms 864 KB Output is correct
18 Correct 3 ms 864 KB Output is correct
19 Correct 4 ms 864 KB Output is correct
20 Correct 2 ms 864 KB Output is correct
21 Correct 4 ms 864 KB Output is correct
22 Correct 2 ms 864 KB Output is correct
23 Correct 3 ms 864 KB Output is correct
24 Correct 3 ms 864 KB Output is correct
25 Correct 3 ms 900 KB Output is correct