QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#235133 | #6812. Draw a triangle | sundage# | WA | 36ms | 3656kb | C++17 | 980b | 2023-11-02 14:47:44 | 2023-11-02 14:47:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int extend_gcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int d = extend_gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
void solve() {
int xx1, yy1, xx2, yy2;
cin >> xx1 >> yy1 >> xx2 >> yy2;
if (xx1 == xx2) {
cout << xx1 + 1 << " " << yy1 << endl;
} else if (yy1 == yy2) {
cout << xx1 << " " << yy1 + 1 << endl;
} else {
xx2 -= xx1;
yy2 -= yy1;
if (xx2 == yy2) {
cout << xx2 + 1 << " " << yy2 << endl;
return;
}
int t = gcd(abs(xx2), abs(yy2));
xx2 /= t;
yy2 /= t;
int x = 0, y = 0;
extend_gcd(yy2, xx2, x, y);
y = x * yy2 / xx2;
x += xx1;
y += yy1;
cout << x << " " << y << endl;
}
return;
}
signed main() {
ios::sync_with_stdio(false);
int tt = 1;
cin >> tt;
while (tt--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
3 1 0 1 4 0 1 0 9 0 0 2 2
output:
2 0 1 1 3 2
result:
ok T=3 (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 3612kb
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:
-249 -250 43307885 98029243 -88895231 -3180782 -90319662 20018677 -56783195 84789747 -81798039 90629147 98942903 -939186 -42532044 -57203371 53500238 -30665575 27115165 46989241 -2657413 26865463 40614091 17923334 -47649925 96037692 92954218 -64534990 86508847 -51415182 -82017717 17392559 75897919 -...
result:
wrong answer wa on query #1 (test case 1)