# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
62608 | imsifile | 십자가 놓기 (FXCUP3_cross) | C++14 | 3 ms | 540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<memory.h>
typedef long long lld;
const lld mod = 1000000007;
struct mat {
lld ba[9][9];
mat operator* (const mat &c){
mat res; memset(res.ba, 0, sizeof(res.ba));
for(int i=0; i<9; i++){
for(int j=0; j<9; j++){
for(int k=0; k<9; k++) res.ba[i][j] += ba[i][k]*c.ba[k][j];
res.ba[i][j] %= mod;
}
}
return res;
}
} base, res;
int N;
int main(){
scanf("%d", &N); N-=4;
if(N<0){ puts("4"); return 0; }
memset(base.ba, 0, sizeof(base.ba));
memset(res.ba, 0, sizeof(res.ba));
for(int i=0; i<9; i++) res.ba[i][i] = 1;
base.ba[0][0] = base.ba[0][1] = base.ba[0][2] = base.ba[0][3] = 1;
base.ba[1][4] = base.ba[1][5] = base.ba[2][6] = base.ba[3][7] = base.ba[3][8] = 1;
base.ba[4][0] = base.ba[4][2] = base.ba[4][3] = 1;
base.ba[6][0] = base.ba[6][1] = base.ba[6][3] = 1;
base.ba[7][0] = base.ba[7][1] = base.ba[7][2] = 1;
base.ba[5][7] = base.ba[8][4] = 1;
for(; N; N>>=1){
if(N&1) res = res*base;
base = base*base;
}
lld sum=0;
for(int i=0; i<9; i++){
for(int j=0; j<9; j++) sum += res.ba[i][j];
}
printf("%lld\n", sum%mod);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |