QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138640#5253. DenormalizationUNos_maricones#RE 0ms0kbC++201.0kb2023-08-12 05:07:582023-08-12 05:07:58

Judging History

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

  • [2023-08-12 05:07:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-12 05:07:58]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

typedef long double lf;
const int MX = 10'000;
const lf EPS = 1e-8;

bool round_integer( const lf &x )
{
	long long y = (long long) ( x + 0.5L );
	return fabs( x - y ) < EPS;
}

int main()
{
	int n;
	scanf("%d", &n );

	vector< lf > x( n );
	for( auto &ref : x )
		scanf("%Lf", &ref );

	for( int r0 = 1; r0 <= MX; ++r0 )
	{
		const lf d = 1.0L * r0 / x[0];
		
		long long sum2 = r0 * r0;
		long long g = r0;

		vector< int > v = { r0 };
		for( int i = 1; i < n; ++ i )
		{
			const lf ri = d * x[i];
			if( round_integer( ri ) )
			{
				const long long rii = (long long) ( ri + 0.5L );
				if( 1 <= rii && rii <= MX )
				{
					g = __gcd( g, rii );
					v.push_back( rii );
					sum2 += rii * rii;
				}
				else
					g = -1;
			}
			else
			{
				g = -1;
				break;
			}
		}

		if( fabsl( d * d - sum2 ) < EPS && g == 1 )
		{
			
			for( auto &r : v )
				printf("%d\n", r );

			return 0;
		}

	}
	assert( false );

	return 0;
};

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

2
0.909840249060
0.414958698174

output:


result: