哪位大佬帮我看看这个 SPJ 有什么问题?
SPJ code:
#include "testlib.h"
int main(int argc, char* argv[]) {
registerTestlibCmd(argc, argv);
int nc = inf.readInt(),i;
double pans,jans;
inf.readEoln();
for(i=1;i<=nc;i++) {
inf.readInt();
inf.readSpace();
inf.readInt();
inf.readSpace();
inf.readEoln();
ouf.readInt();
ouf.readSpace();
ouf.readInt();
ouf.readSpace();
ans.readInt();
ans.readSpace();
ans.readInt();
ans.readSpace();
pans = ouf.readDouble();
jans = ans.readDouble();
ouf.readEoln();
ans.readEoln();
if (fabs(pans - jans)>0.01)
quitf(_wa, "The answer is wrong: expected = %f, found = %f", jans, pans);
}
quitf(_ok, "The answer is correct.");
return 0;
}
题目标程:
#include<bits/stdc++.h>
using namespace std;
struct p{
int a,b,id;
double k;
};
bool cmp(p a,p b)
{
if(a.k<b.k) return true;
else if(a.k>b.k) return false;
else return a.id<b.id;
}
int main() {
int n;
scanf("%d",&n);
p x[10000];
for(int i=0; i<n; i++) {
scanf("%d%d",&x[i].a,&x[i].b);
x[i].id=i;
x[i].k=1.0*x[i].a/x[i].b;
}
sort(x,x+n,cmp);
for(int i=0; i<n; i++) printf("%d %d %.2lf\n",x[i].a,x[i].b,x[i].k);
return 0;
}
提交的 code:
#include<bits/stdc++.h>
using namespace std;
struct p{
int a,b,id;
double k;
};
bool cmp(p a,p b)
{
if(a.k<b.k) return true;
else if(a.k>b.k) return false;
else return a.id<b.id;
}
int main() {
int n;
scanf("%d",&n);
p x[10000];
for(int i=0; i<n; i++) {
scanf("%d%d",&x[i].a,&x[i].b);
x[i].id=i;
x[i].k=1.0*x[i].a/x[i].b;
}
sort(x,x+n,cmp);
for(int i=0; i<n; i++) printf("%d %d %.2lf\n",x[i].a,x[i].b,x[i].k+(1e-5)); //这里有改变
return 0;
}
样例输入 & 输出:
有亿点点长,点这里。
测试点信息:

看 #3。
哪位大佬帮我看看有什么问题QWQ?按理来说,误差小于等于 0.01 就能 AC,但是误差为 10−5 还是 WA,只有标程能过。
我排查出来的问题:
SPJ 似乎没生效?