F.A.Qs Home ProblemSet Status Ranklist 1 Contest LoginRegister
Notice:1:五月份月赛定于5.27日12:30--17:30,鸣谢Claris主持!欢迎大家来玩! 2:关于OJ的注册可看https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671
大视野在线测评-欢迎您
[ New Thread ]
Problem 4417 >> 暴力50,鉴证完毕
Forever_Goodboy @ 2017-10-20 17:48:20
[ Quote ] [ Edit ] [ Delete ] 1#
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define mod 30011
int n,m;
long long f[51][2];
void cal(int a[][3],int b[][3],int to[][3]) {
int c[3][3]={0};
for(int i=1; i<=2; ++i) {
for(int j=1; j<=2; ++j) {
for(int k=1; k<=2; ++k) {
c[i][j]=(c[i][j]+a[i][k]*b[k][j]%mod)%mod;
}
}
}
for(int i=1; i<=2; ++i) {
for(int j=1; j<=2; ++j) {
to[i][j]=c[i][j];
}
}
}
int qpow(int x[][3],int t) {
int Single[3][3]={0};
Single[1][1]=Single[2][2]=1;
for( ; t; t>>=1,cal(x,x,x)) if(t&1) cal(x,Single,Single);
return Single[1][1];
}
int main() {
cin>>n>>m;
int now=0;
f[1][0]=1;
for(int i=2;i<m; ++i) {
for(int j=1; j<=n; ++j) {
f[j][now^1]=(f[j][now^1]+((f[j][now]+f[j-1][now])%mod+f[j+1][now])%mod)%mod;
} now^=1;
}
printf("%lld\n",(f[n][now]+f[n-1][now])%mod);
return 0;
}
[Top] [Previous Page] [Next Page]

HOME Back