QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513259#9168. Square Locatorucup-team956#RE 0ms1668kbC++141.9kb2024-08-10 17:20:462024-08-10 17:20:46

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 17:20:46]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:1668kb
  • [2024-08-10 17:20:46]
  • 提交

answer

#include<stdio.h>
#include<string.h>
#include<algorithm>
typedef long long ll;
struct READ{//快读
	char c,w;
	inline READ(){c=getchar();}
	template<typename type>
	inline READ& operator >>(type& num){
		for(w=1;'0'>c||c>'9';c=getchar())
			w=c=='-'? -1:1;
		for(num=0;'0'<=c&&c<='9';c=getchar())
			num=num*10+(c-'0');
		return *this;
	}
}cin;
ll a,b,c,d;
inline ll sqrt(__int128_t a){
	if(a<=0) return 0;
	ll x=1;
	for(int i=128;i;--i)
		x=a/(x*2)+x/2;
	while(__int128_t(x)*x<a) ++x;
	while(__int128_t(x)*x>a) --x;
	return x;
}
int main(){
	cin>>a>>b>>c>>d;
	const ll ya=sqrt(a);
	ll x=d-b-a*2,y=b-d-a*2;
	__int128_t dd=__int128_t(a)*b*8-__int128_t(a*2+b-d)*(a*2+b-d);
	ll dis=sqrt(dd);
	if(__int128_t(dis)*dis==dd){
		if(std::abs(x+dis)%(ya*4)==0&&std::abs(y+dis)%(ya*4)==0){
			const ll ansx=(x+dis)/(ya*4),ansy=(y+dis)/(ya*4);
			printf("%lld %lld %lld %lld %lld %lld %lld",ya,
				ansx,ansy+ya,ansx-ansy,ansx+ansy+ya,-ansy,ansx+ya);
			return 0;
		}else if(std::abs(x-dis)%(ya*4)==0&&std::abs(y-dis)%(ya*4)==0){
			const ll ansx=(x-dis)/(ya*4),ansy=(y-dis)/(ya*4);
			printf("%lld %lld %lld %lld %lld %lld %lld",ya,
				ansx,ansy+ya,ansx-ansy,ansx+ansy+ya,-ansy,ansx+ya);
			return 0;
		}
	}
	
	std::swap(b,d);
	x=d-b-a*2,y=b-d-a*2;
	dd=__int128_t(a)*b*8-__int128_t(a*2+b-d)*(a*2+b-d);
	dis=sqrt(dd);
	if(__int128_t(dis)*dis==dd){
		if(std::abs(x+dis)%(ya*4)==0&&std::abs(y+dis)%(ya*4)==0){
			const ll ansx=(x+dis)/(ya*4),ansy=(y+dis)/(ya*4);
			printf("%lld %lld %lld %lld %lld %lld %lld",ya,
				-ansy,ansx+ya,ansx-ansy,ansx+ansy+ya,ansx,ansy+ya);
			return 0;
		}else if(std::abs(x-dis)%(ya*4)==0&&std::abs(y-dis)%(ya*4)==0){
			const ll ansx=(x-dis)/(ya*4),ansy=(y-dis)/(ya*4);
			printf("%lld %lld %lld %lld %lld %lld %lld",ya,
				-ansy,ansx+ya,ansx-ansy,ansx+ansy+ya,ansx,ansy+ya);
			return 0;
		}
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1668kb

input:

36 5 10 41

output:

6 -1 2 3 1 4 5

result:

ok Answer is correct

Test #2:

score: -100
Runtime Error

input:

1 1 1 1

output:


result: