防止棕名,放出代码
通过TLE的预处理,获得n的mod
#include <bits/stdc++.h>
#define int long long
using namespace std;
int mod=998244353;
map <int,int> g;
signed main()
{
int n,res=1,cnt;
cin>>n;
g[1]=2;
g[2]=3;
res=6;
for(int i=3;res!=1;i++)
{
g[i]=(g[i-1]*g[i-2])%mod;
res=(res*g[i])%mod;
cnt=i;
}
cout<<cnt;
}
直接暴力做模过cnt的n
#include <bits/stdc++.h>
#define int long long
using namespace std;
int mod=998244353;
int g[37748737];
signed main()
{
int n,res=1,cnt;
cin>>n;
if(n==1ll)
{
cout<<2;
return 0;
}
g[1]=2;
g[2]=3;
res=6;
n%=37748736*1ll;
for(int i=3;i<=n;i++)
{
g[i]=(g[i-1]*g[i-2])%mod;
res=(res*g[i])%mod;
}
cout<<res;
}