QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#402406 | #6812. Draw a triangle | Starrykiller# | RE | 1ms | 3648kb | C++23 | 755b | 2024-04-30 15:19:31 | 2024-04-30 15:19:32 |
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 (!b) 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();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3648kb
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...