标签:des style blog http color io os ar for
30%的数据,满足 2 <= N <= 5 ; 1 <= T <= 30 。
100%的数据,满足 2 <= N <= 10 ; 1 <= T <= 1000000000 。
题解:
好不容易想到了正解,结果妈蛋的调了3节课。。。
结果居然是输出b写成输出a了,我是有多sb。。。这种sb错误考场上犯一个就跪了。。。1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include<vector> 8 #include<map> 9 #include<set> 10 #include<queue> 11 #include<string> 12 #define inf 1000000000 13 #define maxn 100+100 14 #define maxm 100+100 15 #define eps 1e-10 16 #define ll long long 17 #define pa pair<int,int> 18 #define for0(i,n) for(int i=0;i<=(n);i++) 19 #define for1(i,n) for(int i=1;i<=(n);i++) 20 #define for2(i,x,y) for(int i=(x);i<=(y);i++) 21 #define for3(i,x,y) for(int i=(x);i>=(y);i--) 22 #define mod 2009 23 #define num(x,y) 10*(x-1)+(y) 24 using namespace std; 25 inline ll read() 26 { 27 ll x=0,f=1;char ch=getchar(); 28 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} 29 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();} 30 return x*f; 31 } 32 struct matrix 33 { 34 int d[maxn][maxn]; 35 matrix(){memset(d,0,sizeof(d));} 36 }a,b; 37 ll n,m,tot; 38 string s; 39 matrix operator *(matrix &x,matrix &y) 40 { 41 matrix t; 42 for1(i,tot) 43 for1(j,tot) 44 for1(k,tot) 45 t.d[i][j]=(t.d[i][j]+x.d[i][k]*y.d[k][j])%mod; 46 return t; 47 } 48 void ksm(ll cs) 49 { 50 for(;cs;cs>>=1,a=a*a) 51 if(cs&1)b=b*a; 52 } 53 int main() 54 { 55 freopen("input.txt","r",stdin); 56 freopen("output.txt","w",stdout); 57 n=read();m=read();tot=10*n+9; 58 for1(i,n)for1(j,8)a.d[num(i,j)][num(i,j+1)]=1; 59 for1(i,n) 60 { 61 cin>>s; 62 for0(j,n-1)if(s[j]!=‘0‘)a.d[num(i,s[j]-‘0‘)][num(j+1,1)]=1; 63 } 64 for1(i,tot)b.d[i][i]=1; 65 ksm(m); 66 printf("%d\n",b.d[num(1,1)][num(n,1)]); 67 return 0; 68 }
标签:des style blog http color io os ar for
原文地址:http://www.cnblogs.com/zyfzyf/p/3975615.html