QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513304#9168. Square Locatorucup-team956#TL 0ms1664kbC++141.9kb2024-08-10 17:27:462024-08-10 17:27:53

Judging History

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

  • [2024-08-10 17:27:53]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:1664kb
  • [2024-08-10 17:27: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 num*=w,*this;
	}
}cin;
ll a,b,c,d;
inline ll sqrt(__int128_t a){
	if(a<=0) return 0;
	ll x=0x7fff'ffff'ffff'ffff;
	for(int i=256;i;--i)
		x=(__int128_t(x)*x+a)/(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;
}

詳細信息

Test #1:

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

input:

36 5 10 41

output:

6 -1 2 3 1 4 5

result:

ok Answer is correct

Test #2:

score: -100
Time Limit Exceeded

input:

1 1 1 1

output:


result: