QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#138640 | #5253. Denormalization | UNos_maricones# | RE | 0ms | 0kb | C++20 | 1.0kb | 2023-08-12 05:07:58 | 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