求助!!!!!!!!!!!!!!!!!
查看原帖
求助!!!!!!!!!!!!!!!!!
661913
liwenxi1145144444楼主2023/1/21 16:10
#include<bits/stdc++.h>
using namespace std;
long double fab[3],fxy[3],a,b,x,y;
long long ans,t,n;
int main(){
	cin>>t;
	while(t--){
		ans=1;
		cin>>n>>a>>b>>x>>y;
		fab[0]=a;
		fab[1]=b;
		fxy[0]=x;
		fxy[1]=y;
		ans*=(fxy[0]-fab[0]);
		ans%=998244353;
		ans*=(fxy[1]-fab[1]);
		ans%=998244353;
		for(int i=2;i<n;i++){
			int j=i%3;
			if(j==2){
				fab[2]=floor(sqrtl(fab[0]*fab[1]))+1;
				fxy[2]=floor(sqrtl(fxy[0]*fxy[1]))+1;
			}else if(j==1){
				fab[1]=floor(sqrtl(fab[2]*fab[0]))+1;
				fxy[1]=floor(sqrtl(fxy[2]*fxy[0]))+1;
			}else{
				fab[0]=floor(sqrtl(fab[1]*fab[2]))+1;
				fxy[0]=floor(sqrtl(fxy[1]*fxy[2]))+1;
			}
			ans*=(fxy[j]-fab[j]);
			ans%=998244353;
		}
		if(ans<0){
			cout<<ans%998244353+998244353<<"\n";
		}else{
			cout<<ans%998244353<<"\n";
		}
	}
	return 0;
}

4WA,6TLE

2023/1/21 16:10
加载中...