QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#117616 | #6620. Linear Fractional Transformation | lsroi | WA | 1664ms | 3664kb | C++14 | 2.1kb | 2023-07-01 20:25:45 | 2023-07-01 20:25:47 |
Judging History
answer
/*
a = (a1,a2)
*/
#include<bits/stdc++.h>
using namespace std;
const int S = 2;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
int a1, a2, b1, b2, c1, c2, d1, d2;// [-100, 100] int ?
int r1, s1, r2, s2, r3, s3;
int p1, q1, p2, q2, p3, q3;
cin >> p1 >> q1 >> r1 >> s1;
cin >> p2 >> q2 >> r2 >> s2;
cin >> p3 >> q3 >> r3 >> s3;
bool flag = false;
for (int i = -S; i <= S; i++) {//枚举a1,a2
for (int j = -S; j <= S; j++) {
for (int k = -S; k <= S; k++) {//枚举c1,c2
for (int l = -S; l <= S; l++) {
for (int m = -S; m <= S; m++) {//枚举d1,d2
for (int n = -S; n <= S; n++) {
int o1 = p1*(r1*k-s1*l-i) - q1*(r1*l+s1*k-j) + (r1*m-s1*n);
int o2 = p2*(r2*k-s2*l-i) - q2*(r2*l+s2*k-j) + (r2*m-s2*n);
int o3 = p3*(r3*k-s3*l-i) - q3*(r3*l+s3*k-j) + (r3*m-s3*n);
int u1 = p1*(r1*l+s1*k-j) + q1*(r1*k-s1*l-i) + (r1*n+s1*m);
int u2 = p2*(r2*l+s2*k-j) + q2*(r2*k-s2*l-i) + (r2*n+s2*m);
int u3 = p3*(r3*l+s3*k-j) + q3*(r3*k-s3*l-i) + (r3*n+s3*m);
if (o1 == o2 && o1 == o3 && u1 == u2 && u1 == u3) {
a1 = i; a2 = j;
b1 = o1; b2 = u1;
c1 = k; c2 = l;
d1 = m; d2 = n;
if (a1*d1-a2*d2 == b1*c1-b2*c2) continue;
flag = true;
break;
}
}if (flag) break;
}if (flag) break;
}if (flag) break;
}if (flag) break;
}if (flag) break;
}
// cout << flag << "---\n";
// cout << a1 << ' ' << a2 << "\n";
// cout << b1 << ' ' << b2 << "\n";
// cout << c1 << ' ' << c2 << "\n";
// cout << d1 << ' ' << d2 << "\n";
int p, q, r, s;
cin >> p >> q;
// (a,b)/(c,d)=(r,s)
int a, b, c, d;
a = a1*p-a2*q+b1;
b = a1*q+a2*p+b2;
c = c1*p-c2*q+d1;
d = c1*q+c2*p+d2;
// cout << a << ' ' << b << ' ' << c << ' ' << d << "\n";
r = a * c + b * d;
s = b * c - a * d;
cout << fixed << setprecision(10) << (double)r/(c*c+d*d) << ' ' << (double)s/(c*c+d*d) << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3648kb
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: 1664ms
memory: 3664kb
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:
-nan -nan -nan -nan -nan -nan 0.3333333333 -0.6666666667 -nan -nan -1.0000000000 0.0000000000 -1.5000000000 0.5000000000 -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan 1.0000000000 0.0000000000 0.0000000000 2.0000000000 1.5000000000 0.5000000000 2.0000000000 0.0000000000 -1.0000000000 -1.00000000...
result:
wrong output format Expected double, but "-nan" found