为甚第二个点总是wrong,不知道原因,照着蓝书打的还是错了
查看原帖
为甚第二个点总是wrong,不知道原因,照着蓝书打的还是错了
233198
starseven楼主2020/5/1 10:33
#include<cstdio>
#include<iostream>
#include<cstring>
#define ll long long
#define Starseven main
#define ri register int
using namespace std;
int prime[200000+20],cnt;
bool use[200000+20];

#define B {ok=true;break;}
int Starseven(void){
	int n;
	cin>>n;
	for(ri i=2;i<=200000;i++){
		if(!use[i]) prime[++cnt]=i;
		use[i]=true;
		for(ri j=1;j<=cnt&&prime[j]*i<=200000;j++){
			use[prime[j]*i]=true;
			if(i%prime[j]==0) break;
		}
	}
	while(n--){
		ll a0,a1,b0,b1;
		cin>>a0>>a1>>b0>>b1;
		bool ok=false;
		ll ans=1;
		for(ri i=1;i<=cnt;i++){
			int num1=0,num2=0,num3=0,num4=0;
			while(a0>1&&a0%prime[i]==0){
				num1++;a0/=prime[i];
			}
			while(a1>1&&a1%prime[i]==0){
				num2++;a1/=prime[i];
			}
			while(b0>1&&b0%prime[i]==0){
				num3++;b0/=prime[i];
			}
			while(b1>1&&b1%prime[i]==0){
				num4++;b1/=prime[i];
			}
			if(num1>num2){
				if(num3<num4){
					if(num2==num4) continue;
					else B
				}
				else if(num3==num4){
					if(num2<=num4) continue;
						else B
					}
			}
			else if(num1==num2){
				if(num2<=num4){
					if(num3<num4) continue;
					else if(num3==num4) ans*=num4-num2+1;
					else B
				}
				else B
			}
			else B
//			if(num1>num2&&num3<num4&&num2==num4) continue;
//			else if(num1>num2&&num3==num4&&num2<=num4) continue;
//			else if(num1==num2&&num3<num4&&num2<=num4) continue;
//			else if(num1==num2&&num3==num4&&num2<=num4) ans*=num4-num2+1;
//			else{
//				ok=true;break;
//			}
		}
		if(ok){
			cout<<"0"<<endl;
			continue;
		}
		else{
			cout<<ans<<endl;
		}
	}
	return 0;
} 
2020/5/1 10:33
加载中...