QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#138653 | #5252. Deforestation | UNos_maricones# | ML | 0ms | 0kb | C++20 | 1.1kb | 2023-08-12 06:09:09 | 2023-08-12 06:09:12 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long double lf;
const int MX = 10'000;
const lf EPS = 2e-7;
int main()
{
int n;
scanf("%d", &n );
vector< lf > x( n );
for( auto &ref : x )
scanf("%Lf", &ref );
const lf mx = *max_element( x.begin(), x.end() );
set< long long > cn;
for( int r = 1; r <= MX; ++r )
{
const long long s2 = (long long) ( 1.0L * ( r * r ) / ( mx * mx ) + 0.5L );
cn.insert( s2 - 1 );
cn.insert( s2 );
cn.insert( s2 + 1 );
}
for( auto &s2 : cn )
{
if( s2 <= 0 ) continue;
const lf d = sqrtl( s2 );
long long sum2 = 0, g = 0;
vector< int > v;
for( int i = 0; i < n; ++ i )
{
const long long ri = (long long) ( d * x[i] + 0.5L );
if( 1 <= ri && ri <= MX && fabsl( ri / d - x[i] ) < EPS )
{
g = __gcd( g, ri );
v.push_back( ri );
sum2 += ri * ri;
}
else
{
g = -1;
break;
}
}
if( sum2 == s2 && g == 1 )
{
for( auto &rr : v )
printf("%d\n", rr );
return 0;
}
}
assert( false );
return 0;
};
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Memory Limit Exceeded
input:
999900000 7339 3 14947 2 12850 3 8986 10 11599 9 8889 10 10711 4 8015 1 11626 0 9492 1 7017 0 8863 0 8632 0 5321 5 9906 0 11687 0 9845 0 10469 0 11708 0 14950 5 11934 0 11922 0 13101 0 12000 0 9082 0 9273 5 12296 0 6119 0 9201 0 12652 0 12957 0 7454 5 12515 0 12976 0 10358 0 13997 0 8371 0 10181 5 8...