这道题:Walk
我在 Dev-C++ 中一直过不了样例(假),其实是这个情况:

这个情况就是众所周知的运行错误,我调了 n 年(一个小时),最后一气之下把代码粘贴到在线IDE,运行了一下,明明能过样例啊,于是我交了一遍就AC了。
代码:
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
const int mod = 1e9+7;
#define int long long
int n;
int k;
struct node
{
int a[N][N];
node()
{
memset(a,0,sizeof(a));
}
};
node v;
node operator *(const node&A,const node&B)
{
node C;
for(int k = 1;k<=n;k++)
{
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=n;j++)
{
C.a[i][j] = (C.a[i][j]+A.a[i][k]*B.a[k][j]%mod)%mod;
}
}
}
return C;
}
void fast_pow(node &a,int b)
{
node ans;
for(int i = 1;i<=n;i++)
{
ans.a[i][i] = 1;
}
while(b)
{
if(b&1)
{
ans = ans*a;
}
a = a*a;
b>>=1;
}
a = ans;
}
signed main()
{
scanf("%lld %lld",&n,&k);
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=n;j++)
{
scanf("%lld",&v.a[i][j]);
}
}
fast_pow(v,k);
int ans = 0;
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=n;j++)
{
ans = (ans+v.a[i][j])%mod;
}
}
printf("%lld",ans);
return 0;
}
请问这是怎么回事呢?