QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140798#5152. Circular Caramel CookieAs3b_team_f_masr#WA 218ms61196kbC++141.4kb2023-08-16 20:30:512023-08-16 20:30:53

Judging History

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

  • [2023-08-16 20:30:53]
  • 评测
  • 测评结果:WA
  • 用时:218ms
  • 内存:61196kb
  • [2023-08-16 20:30:51]
  • 提交

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 = 8e5 + 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;
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 if (sq[pos] * x > mx) {
                mx = sq[pos] * x;
                id1 = x;
                id2 = sq[pos];
            }
        }
        ll cnt = 1ll * 4 * mp[id1] * mp[id2];

        if (id1 != id2)cnt += 1ll * mp[min(id1, id2)] * 4;
        if (cnt >=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: 100
Accepted
time: 183ms
memory: 61196kb

input:

11

output:

2.23606797685

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #2:

score: 0
Accepted
time: 182ms
memory: 60704kb

input:

59

output:

4.99999999959

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 183ms
memory: 60176kb

input:

1

output:

1.41421356224

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #4:

score: 0
Accepted
time: 193ms
memory: 61080kb

input:

2

output:

1.41421356224

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #5:

score: 0
Accepted
time: 180ms
memory: 60636kb

input:

3

output:

1.41421356224

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #6:

score: 0
Accepted
time: 192ms
memory: 59992kb

input:

4

output:

2.23606797685

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #7:

score: -100
Wrong Answer
time: 218ms
memory: 59344kb

input:

1000000000

output:

22360.83775264222

result:

wrong answer 1st numbers differ - expected: '17841.8813190', found: '22360.8377526', error = '0.2532780'