10 分代码:
#include<bits/stdc++.h>
#define int long long
const int mod=998244353;
using namespace std;
int fpow(int a,int b)
{
long long t=1;
while(b)
{
if(b&1)
t*=a%mod;
b>>=1;
a*=a%mod;
}
return t;
}
signed main()
{
int k,n;
cin>>n>>k;
cout<<fpow(fpow(2,k)-1,n);
return 0;
}
AC 代码:
#include<bits/stdc++.h>
#define int long long
const int mod=998244353;
using namespace std;
int fpow(int a,int b)
{
int t=1;
while(b)
{
if(b&1)
t=t*a%mod;
b>>=1;
a=a*a%mod;
}
return t;
}
signed main()
{
int k,n;
cin>>n>>k;
cout<<fpow(fpow(2,k)-1,n);
return 0;
}
可以发现,将t*=a%mod改成t=t*a%mod就能过,求原因。