QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659878#6812. Draw a triangleError_666RE 0ms3604kbC++23678b2024-10-19 22:55:332024-10-19 22:55:34

Judging History

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

  • [2024-10-19 22:55:34]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3604kb
  • [2024-10-19 22:55:33]
  • 提交

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) {
			int xx = (x % t) + t;
			int s = (xx - x) / t;
			int yy = y - (a / __gcd(a, b)) * s;
			x = xx, y = yy;
		}
		
		cout << x + x1 << ' ' << y + y1 << endl;
	}
	return 0;
}

详细

Test #1:

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

input:

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

output:

2 0
1 1
1 0

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:

66620474 -33485015
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: