QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#402404#6812. Draw a triangleStarrykiller#WA 1ms3692kbC++23755b2024-04-30 15:16:192024-04-30 15:16:19

Judging History

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

  • [2024-04-30 15:16:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3692kb
  • [2024-04-30 15:16:19]
  • 提交

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();
    
}

詳細信息

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)