月赛T1
  • 板块学术版
  • 楼主AAA404
  • 当前回复22
  • 已保存回复22
  • 发布时间2023/8/26 18:06
  • 上次更新2023/11/3 01:03:28
查看原帖
月赛T1
723198
AAA404楼主2023/8/26 18:06

被T1恶心到了,一直60

求hack,最后一个样例过不了,调不出来

就是简单的模拟

#include<bits/stdc++.h>
using namespace std;
long long a,b,k,ans=1;
const long long mod=998244353;
inline long long qpow(long long a,int b)
{
	long long ans=1,base=a;
	while(b)
	{
		if(b&1)
		{
			ans*=base;
			ans%=mod;
		}
		base*=base;
		base%=mod;
		b>>=1;
	}
	return ans;
}
inline long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
signed main()
{
	clock_t c1=clock();
#ifdef LOCAL
 	freopen("1.in","r",stdin);
 	freopen("1.out","w",stdout);
#endif
    ios::sync_with_stdio(0);
 	cin.tie(0);cout.tie(0);
	cin>>a>>b>>k;
	if(a==b)
	{
		cout<<1;
		return 0;
	}
	// if(b<a)
	// {
		for(int i=1;i<=k;i++)
		{
			if(i%a==0)ans=(ans*2ll)%mod;
			if(i%b==0)ans=((ans-1ll)/2ll+1ll+mod)%mod;
			// if(ans==62166352)cout<<i<<endl;
		}
		cout<<ans;
		return 0;
	// }
	// long long add=k/a,suf=k/b;
	// long long lcm=a/gcd(a,b)*b;
	// long long llcm=k/lcm;
	// cout<<qpow(2,add-suf-llcm+(llcm>0))<<endl;
#ifdef LOCAL
	cerr<<"Time used:"<<clock()-c1<<"ms";
#endif
 	return 0;
}
2023/8/26 18:06
加载中...