QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141468#5253. DenormalizationPhantomThreshold#WA 1ms3728kbC++201.2kb2023-08-17 14:33:372023-08-17 14:33:38

Judging History

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

  • [2023-08-17 14:33:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2023-08-17 14:33:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long double db;
const db eps=1e-11;
const db lim=10001;
int sign(db k){
	if (k<-eps) return -1;
	else if (k>eps) return 1;
	return 0;
}
long long div(db a,db b){
	long long tmp=a/b+0.5;
	return tmp;
}
db mod(db a,db b){
	return a-div(a,b)*b;
}

db gcd(db a,db b){
//	cerr << "gcd : " << a << " " << b << endl;
	if (sign(b)==0 || fabs(a/b)>=lim) return a;
	return gcd(b,fabs(mod(a,b)));
}

const int maxn=10000;
int n;
db a[maxn+50];
long long ans[maxn+50];

int main(){
	ios_base::sync_with_stdio(false);
	cerr << fixed << setprecision(12);

	cin >> n;
//	db D=1;
	for (int i=1;i<=n;i++){
		cin >> a[i];
	//	D+=a[i]*a[i];
	}
	/*
	D=sqrtl(D);
	cerr << "D : " << D << endl;
	cerr << "1/D : " << 1/D << endl;
	for (int i=1;i<=n;i++) a[i]=((long long)(a[i]/D*1e12))/1e12;
	for (int i=1;i<=n;i++) cerr << a[i] << " ";
	cerr << endl;
	*/
	
	db g=a[1];
	for (int i=2;i<=n;i++){
	//	cerr << "----------------" << endl;
		g=gcd(g,a[i]);
	//	cerr << "g : " << g << endl;
	}
	
	for (int i=1;i<=n;i++) ans[i]=div(a[i],g);
	for (int i=1;i<=n;i++) cout << ans[i] << " \n"[i==n];
	return 0;	
}
/*
3
1 9999 10000
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
0.909840249060
0.414958698174

output:

9665 4408

result:

ok good solution

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3616kb

input:

3
0.005731604132
0.696198848562
0.717826101486

output:

399538065 48530557014 50038147314

result:

wrong answer Integer parameter [name=r_i] equals to 399538065, violates the range [1, 10000]