QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#659872#6812. Draw a triangleError_666RE 0ms3532kbC++23628b2024-10-19 22:52:262024-10-19 22:52:27

Judging History

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

  • [2024-10-19 22:52:27]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3532kb
  • [2024-10-19 22:52:26]
  • 提交

answer

#include <iostream>
#include <algorithm>
using namespace std;

#define int long long

int T, x1, y1, x2, y2;

void exgcd(int &x,int &y,int a,int b) {
    if(!b) {
        x=1;
        y=0;
        return;
    }
    exgcd(x,y,b,a%b);
    int t=x;
    x=y;
    y=t-a/b*y;
}

signed main()
{
	cin >> T;
	while (T--) {
		cin >> x1 >> y1 >> x2 >> y2;
		int a = x2 - x1;
		int b = y2 - y1;
		int x, y;
		exgcd(x, y, -b, a);
		
		int t = b / __gcd(a, b);
		if (x <= 0) {
			x = ((x % t) + t) % t;
			y = (__gcd(a, b) + b * x) / a;
		}
		
		cout << x + x1 << ' ' << y + y1 << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 0 1 4
0 1 0 9
0 0 2 2

output:

2 0
1 1
0 1

result:

ok T=3 (3 test cases)

Test #2:

score: -100
Runtime Error

input:

50000
66620473 -33485015 66620223 -33485265
43307886 98029243 43307636 98028994
-88895230 -3180782 -88895480 -3181030
-90319745 20018595 -90319995 20018348
-56783257 84789686 -56783507 84789440
-81798038 90629147 -81798288 90628902
98942945 -939146 98942695 -939390
-42532151 -57203475 -42532401 -572...

output:

66620473 -33485014
43307887 98029244
-88895229 -3180781
-90319662 20018677
-56783195 84789747
-81798037 90629148
98942987 -939105
-42532044 -57203371
53500238 -30665575
27115165 46989241
-2657411 26865464
40614273 17923507
-47649883 96037731
92954372 -64534845
86508883 -51415149
-82017683 17392590
7...

result: