请看题目
by Provicy @ 2020-02-13 11:05:56
山前谔谔
by ix35 @ 2020-02-13 11:07:48
~~难道你想模998244353?~~
by dingcx @ 2020-02-13 11:07:51
谔谔
by Meatherm @ 2020-02-13 11:10:00
山前谔谔
by SisconHL @ 2020-02-13 11:23:19
~~%114514~~
by Star_Wind @ 2020-02-13 11:23:42
@[ix35](/user/113546) %[ix35](/user/113546)
by tzc_wk @ 2020-05-25 13:22:11
不用开long long
by grass8cow @ 2020-06-14 16:44:57
@[grass8woc](/user/223624) 就因为你这句话让我调了半天!明明要的!
by O2人 @ 2021-10-28 07:00:31
@[O2人](/user/98390) 你自己写丑了。
```cpp
#include<bits/stdc++.h>
using namespace std;
int head[121],cnt,n,m,T,s,t,mod=45989,sum;
struct qq
{
int a[121][121];
}ans,p;
qq mul(qq a,qq b)
{
qq c;
for(int i=0;i<cnt;i++)for(int j=0;j<cnt;j++){c.a[i][j]=0;for(int k=0;k<cnt;k++)c.a[i][j]=(c.a[i][j]+a.a[i][k]*b.a[k][j])%mod;}
return c;
}
int read()
{
int now=0;char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')now=now*10+c-'0',c=getchar();
return now;
}
struct edge
{
int v,nex;
}o[121];
void add(int u,int v)
{
o[cnt++]=(edge){v,head[u]};head[u]=cnt-1;
o[cnt++]=(edge){u,head[v]};head[v]=cnt-1;
}
int main()
{
n=read(),m=read(),T=read(),s=read(),t=read();T--;
for(int i=0;i<n;i++)head[i]=-1;
for(int i=0,a,b;i<m;i++)
{
a=read();b=read();
add(a,b);
}
for(int i=0;i<cnt;i++)for(int j=head[o[i].v];j>-1;j=o[j].nex)if((i^1)!=j)p.a[i][j]=1;
for(int i=head[s];i>-1;i=o[i].nex)ans.a[0][i]=1;
while(T)
{
if(T&1)ans=mul(ans,p);
p=mul(p,p);
T>>=1;
}
for(int i=head[t];i>-1;i=o[i].nex)sum=(sum+ans.a[0][i^1])%mod;
printf("%d",sum);
return 0;
}
```
AC代码。没有 long long 吧?
by grass8cow @ 2021-10-28 12:57:46