QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#217375 | #6620. Linear Fractional Transformation | zhuibao | WA | 219ms | 3964kb | C++20 | 2.3kb | 2023-10-16 20:13:05 | 2023-10-16 20:13:05 |
Judging History
answer
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll>pi; typedef complex<double>cx;
#define int ll
#define X first
#define Y second
#define fer(i,a,n) for(int i=a;i<=n;i++)
#define ref(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,x) memset(a,x,sizeof a)
#define ac IO;int t;cin>>t;while(t--)solve()
#define AC signed main(){IO;solve();}
#define NO {cout<<"NO"<<endl;return;}
#define YES {cout<<"YES"<<endl;return;}
#define re(a) {cout<<a<<endl;return;}
#define all(v) v.begin(),v.end()
//ofstream fout("1.out", ios::out);
//ifstream fin("1.in", ios::in);
//#define cout fout
//#define cin fin
//--------------------瑞神神中神--------------------
const double eps=1e-6;
complex<double>a[5][5],z[5],w[5];
int n=3;
double ffabs(complex<double>x)
{
return x.real()*x.real()+x.imag()*x.imag();
}
void gauss()
{
int r,c;
for(r=0,c=0;c<n;c++)
{
int t=r;
for(int i=c;i<n;i++)
{
if(ffabs(a[i][c])>ffabs(a[t][c]))t=i;
}
if(ffabs(a[t][c])<eps)continue;
swap(a[t],a[r]);
for(int i=n;i>=c;i--)a[r][i]/=a[r][c];
for(int i=r+1;i<n;i++)
{
if(ffabs(a[i][c])>eps)
{
for(int j=n;j>=c;j--)
a[i][j]-=a[r][j]*a[i][c];
}
}
r++;
}
for(int i=n-1;i>=0;i--)
for(int j=i+1;j<n;j++)
a[i][n]-=a[j][n]*a[i][j];
}
void solve()
{
for(int i=0;i<3;i++)
{
double za,zb,wa,wb;
cin>>za>>zb>>wa>>wb;
z[i].real(za);z[i].imag(zb);w[i].real(wa);w[i].imag(wb);
a[i][0]=z[i];a[i][1].real(1);a[i][2]=w[i];a[i][3]=w[i]*z[i];
}
complex<double>z0;
double za,zb;cin>>za>>zb;
z0.real(za);z0.imag(zb);
complex<double>c=(w[0]-w[1])/(z[0]-z[1]);
complex<double>d=w[0]-(w[0]-w[1])/(z[0]-z[1])*z[0];
complex<double>ans;
if(ffabs(c*z[2]+d-w[2])<eps)
{
ans=c*z0+d;
}
else
{
gauss();
ans=(a[0][3]*z0+a[1][3])/(z0-a[3][3]);
}
cout<<setprecision(12)<<ans.real()<<' '<<ans.imag()<<'\n';
}
signed main()
{
ac;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3900kb
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 0 0 1
result:
ok 4 numbers
Test #2:
score: -100
Wrong Answer
time: 219ms
memory: 3964kb
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:
2.2 1.4 0.423076923077 -0.384615384615 4 -4 0.8 -0.6 -1.33333333333 -0.666666666667 -0.7 0.1 -1.5 1.5 -1.3 0.4 -4.5 0.5 0.411764705882 -0.352941176471 0.4 -1.2 -1 -1 0.615384615385 -1.07692307692 -2 -2.22044604925e-16 -nan -nan 2 0 -0.71724137931 -0.606896551724 -1.46153846154 1.69230769231 -1.29411...
result:
wrong answer 1st numbers differ - expected: '1.0000000', found: '2.2000000', error = '1.2000000'