90pts求条
  • 板块P11397 界分数
  • 楼主ZJH234567
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/15 10:43
  • 上次更新2024/12/15 14:11:09
查看原帖
90pts求条
1210041
ZJH234567楼主2024/12/15 10:43

已经用上龟速乘了,还是90pts(不想用int_128);

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll n,ans=1;
ll qp(ll a,ll b){
	ll c=0;
	while(b){
		if(b&1) (c+=a)%=mod;
		b>>=1;
		(a+=a)%=mod;
	}
	return c%mod;
}
int main(){
	cin>>n;
	n--;
	ll cnt=1;
	for(ll i=2;;i++){
		ll now=qp(i,cnt)%mod;
		if(n>=cnt) (n-=cnt)%=mod,(ans+=now)%=mod;
		else{
			cout<<(qp(n,i)%mod+ans%mod)%mod<<endl;
			return 0;
		}
		ans%=mod,(cnt*=2)%=mod;
	}
	return 0;
}
2024/12/15 10:43
加载中...