QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#117667#6620. Linear Fractional TransformationlsroiWA 123ms3656kbC++141.4kb2023-07-01 22:02:142023-07-01 22:02:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-01 22:02:15]
  • 评测
  • 测评结果:WA
  • 用时:123ms
  • 内存:3656kb
  • [2023-07-01 22:02:14]
  • 提交

answer

/*
https://zhuanlan.zhihu.com/p/625240527?utm_id=0

解方程:
(z-z1)(z3-z2)	(w-w1)(w3-w2)
------------- = -------------
(z-z2)(z3-z1)	(w-w2)(w3-w1)
*/
#include<bits/stdc++.h>
using namespace std;
const int S = 10;
class Complex
{
public:
	double r, i;
	Complex() :r(0), i(0) {}
	Complex(double a, double b)
	{
		r = a;
		i = b;
	}
	~Complex() {}
	Complex operator -(Complex b)
	{
		Complex c;
		c.r = r - b.r;
		c.i = i - b.i;
		return c;
	}
	Complex operator +(Complex b)
	{
		Complex c;
		c.r = r + b.r;
		c.i = i + b.i;
		return c;
	}
	Complex operator *(Complex b)
	{
		Complex c;
		c.r = r * b.r - i * b.i;
		c.i = r * b.i + i * b.r;
		return c;
	}
	Complex operator /(Complex b)
	{
		Complex c;
		c.r = (r*b.r+i*b.i) / (b.r*b.r+b.i*b.i);
		c.i = (-r*b.i+i*b.r) / (b.r*b.r+b.i*b.i);
		return c;
	}
};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		int r1, s1, r2, s2, r3, s3;
		int p1, q1, p2, q2, p3, q3, p, q;
		cin >> p1 >> q1 >> r1 >> s1;
		cin >> p2 >> q2 >> r2 >> s2;
		cin >> p3 >> q3 >> r3 >> s3;
		cin >> p >> q;
		Complex z1(p1, q1), z2(p2, q2), z3(p3, q3), z(p, q);
		Complex w1(r1, s1), w2(r2, s2), w3(r3, s3), w;
		Complex tmp = ((z-z1)*(z3-z2)*(w3-w1))/((z-z2)*(z3-z1)*(w3-w2));
		Complex e(1, 0);//单位元
		w = (w1 - tmp * w2) / (e - tmp);
		cout << fixed << setprecision(10) << w.r << ' ' << w.i << "\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

input:

2
-1 0 0 -1
0 1 -1 0
1 0 0 1
0 -1
-1 0 -1 0
0 1 0 -1
1 0 1 0
0 -1

output:

1.0000000000 0.0000000000
0.0000000000 1.0000000000

result:

ok 4 numbers

Test #2:

score: -100
Wrong Answer
time: 123ms
memory: 3628kb

input:

100000
0 0 -1 1
1 1 1 0
1 0 1 -1
-1 0
-1 -1 -1 1
1 -1 1 -1
-1 0 1 0
-1 -1
-1 -1 0 -1
-1 1 -1 -1
0 -1 0 0
1 1
1 0 0 -1
0 0 0 0
-1 -1 1 0
1 1
-1 -1 0 -1
0 1 1 -1
1 0 -1 -1
1 -1
0 1 1 -1
1 0 1 0
0 -1 0 1
-1 -1
1 1 -1 1
0 0 -1 -1
0 1 0 1
1 0
1 1 1 -1
0 1 -1 -1
1 0 -1 0
1 -1
1 0 -1 1
-1 -1 1 0
0 -1 0 1
0...

output:

1.0000000000 1.6666666667
-1.0000000000 1.0000000000
-1.5000000000 -0.5000000000
0.3333333333 -0.6666666667
-0.3846153846 -0.9230769231
-1.0000000000 -0.0000000000
-1.5000000000 0.5000000000
-0.8536585366 -0.3170731707
-1.3333333333 0.3333333333
0.1724137931 -0.0689655172
-nan -nan
-0.6666666667 -1....

result:

wrong output format Expected double, but "-nan" found