QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140763 | #5152. Circular Caramel Cookie | As3b_team_f_masr# | TL | 0ms | 0kb | C++14 | 1.4kb | 2023-08-16 19:45:07 | 2023-08-16 19:45:29 |
answer
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, 0, 0, 1, -1, 1};
int dj[] = {0, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 1e9 + 7;
const int N = 2e6+ 5, M = 30005;
#define EPS 1e-9
int t, m, ans;
ll n;
int main() {
//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//freopen("output.txt", "w", stdout);
cin >> n;
/*for(int i = 1; i < n ;++i){
int u,v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}*/
map<ll,int> mp;
vector<ll>sq;
for(int i=0;i<N;i++)
{
sq.push_back(1ll*i*i);
mp[1ll*i*i]=i;
}
ld lo=0,hi=N;
while(hi-lo>EPS) {
ld mid = (lo + hi) / 2.0;
ll y = 1.0 * mid * mid;
ll id1 = 0, id2 = 0, mx = 0;
for (auto x:sq) {
if (x > y)break;
int pos = upper_bound(sq.begin(), sq.end(), y - x) - sq.begin() - 1;
if (pos == -1)continue;
else {
id1=sq[pos],id2=x;
ll cnt = 1ll * 4 * mp[id1] * mp[id2];
cnt += 1ll * mp[min(id1, id2)] * 4 * (mp[max(id1,id2)]-mp[min(id1, id2)]);
mx=max(cnt,mx);
}
}
if (mx >=n)
{
hi=mid;
}
else lo=mid;
}
cout<<fixed<<setprecision(11)<<lo;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
11