QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402404 | #6812. Draw a triangle | Starrykiller# | WA | 1ms | 3692kb | C++23 | 755b | 2024-04-30 15:16:19 | 2024-04-30 15:16:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int exgcd(int a, int b, int &x, int &y) {
if (!a) return x=1, y=0, abs(a);
int d=exgcd(b,a%b,x,y);
int z=x; x=y, y=z-y*(a/b);
return d;
}
void solve() {
int x1, y1, x2, y2;
cin>>x1>>y1>>x2>>y2;
if (x1==x2) {
cout<<x1+1<<' '<<y1<<'\n';
return;
}
if (y1==y2) {
cout<<x1<<' '<<y1+1<<'\n';
return;
}
int x=x2-x1, y=y2-y1;
int a, b;
int g=exgcd(y,x,a,b);
assert(a*y+b*x==g);
cout<<x1+a<<' '<<y1+b<<'\n';
//
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int T; cin>>T;
while (T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3692kb
input:
3 1 0 1 4 0 1 0 9 0 0 2 2
output:
2 0 1 1 1 -1
result:
wrong answer wa on query #3 (test case 3)