QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418535 | #8674. Riddle of the Sphinx | by_chance# | WA | 1ms | 3740kb | C++14 | 1.2kb | 2024-05-23 14:24:06 | 2024-05-23 14:24:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
ll a[5][4]={{1,1,1,0},{1,0,0,0},{0,0,1,0},{0,1,0,0},{1,2,3,0}};
db b[3][4],c[3],eps=1e-10;
void calc(int p1,int p2,int p3){
for(int j:{0,1,2,3})
b[0][j]=a[p1][j],b[1][j]=a[p2][j],b[2][j]=a[p3][j];
for(int i=0;i<3;i++){
int p=i;for(;p<3;p++)if(b[p][i]>eps)break;
for(int j=0;j<=3;j++)swap(b[p][j],b[i][j]);
for(int j=i+1;j<3;j++){
db d=b[j][i]/b[i][i];
for(int k=0;k<=3;k++)b[j][k]-=d*b[i][k];
}
}
for(int j=3-1;j>=0;j--){
c[j]=b[j][3];
for(int k=j+1;k<3;k++)
c[j]-=b[j][k]*c[k];
c[j]/=b[j][j];
}
int flag=1,cnt=0;
for(int j=0;j<3;j++)
if(abs(ll(c[j]+0.5)-c[j])>eps||c[j]<0)flag=0;
for(int i=0;i<5;i++){
db x=a[i][0]*c[0]+a[i][1]*c[1]+a[i][2]*c[2];
cnt+=(abs(x-a[i][3])<eps);
}
if(cnt>=4&&flag==1){
for(int j=0;j<3;j++)
cout<<ll(c[j]+0.5)<<' ';
cout<<endl;exit(0);
}
}
int main(){
for(int i=0;i<5;i++){
cout<<a[i][0]<<' '<<a[i][1]<<' '<<a[i][2]<<endl;
cin>>a[i][3];
}
calc(0,1,2);calc(0,3,4);calc(1,2,3);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3652kb
input:
6 1 3 2 14
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 1 2 3
result:
ok correct!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
10000 9998 1 1 10003
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 9998 1 1
result:
ok correct!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
9999 3333 3333 3333 19998
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 3333 3333 3333
result:
ok correct!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
2107 893 712 503 4035
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 893 503 712
result:
ok correct!
Test #5:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
2182 866 947 367 4443
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 868 367 947
result:
ok correct!
Test #6:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
2304 684 794 827 4717
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3 684 827 793
result:
ok correct!
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3740kb
input:
771 308 440 21 1674
output:
1 1 1 1 0 0 0 0 1 0 1 0 1 2 3
result:
wrong answer format Unexpected end of file - int32 expected