QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#46281#4497. MapmiaomiaoziAC ✓382ms3840kbC++171.2kb2022-08-28 18:55:492022-08-28 18:55:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-28 18:55:51]
  • 评测
  • 测评结果:AC
  • 用时:382ms
  • 内存:3840kb
  • [2022-08-28 18:55:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917

#ifndef LOCAL
#define LOG(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long LL;
typedef pair <int, int> PII;

constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1);

int multi_cases = 1;

using C = complex <double>;
void A_SOUL_AvA () {
    vector <complex<double>> a(4), b(4);
    for (int i = 0; i < 4; i++) {
        double x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    for (int i = 0; i < 4; i++) {
        double x, y;
        cin >> x >> y;
        b[i] = {x, y};
    }

    C x1 = a[0], y1 = a[1];
    C x2 = b[0], y2 = b[1];
    C r = (y1 - y2) / (x1 - x2);
    C t = y1 - r * x1;
    C ans = t / (C(1, 0) - r);
    cout << ans.real() << " " << ans.imag() << endl;
}

int main () {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int T = 1;
    for (multi_cases && cin >> T; T; T--) {
        A_SOUL_AvA ();
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 382ms
memory: 3840kb

input:

100000
0 5
15 5
15 0
0 0
3 2
9 5
10 3
4 0
-605 604
604 605
605 -604
-604 -605
569 -338
568 -337
569 -336
570 -337
-964 963
963 964
964 -963
-963 -964
-364 838
-365 839
-364 840
-363 839
-664 663
663 664
664 -663
-663 -664
-307 -424
-308 -423
-307 -422
-306 -423
-866 865
865 866
866 -865
-865 -866
12...

output:

6.000000000000 2.000000000000
568.808264462810 -336.251239669422
-364.246369294606 838.376037344398
-306.450301204819 -422.912650602410
119.470554272517 796.609122401847
426.696564885496 50.239821882952
-138.701657458564 -400.855248618784
190.891911764706 -43.827205882353
-392.426023084995 -700.8384...

result:

ok 200000 numbers