QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96484#5152. Circular Caramel CookieRoomGamadan#WA 6ms3644kbC++201.6kb2023-04-13 22:11:212023-04-13 22:11:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 22:11:25]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3644kb
  • [2023-04-13 22:11:21]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

#define el '\n'
#define F first
#define S second

typedef long long ll;
typedef long double ld;

bool multipleTestCases = 1, sublime = 0;
const int N = 1e5 + 5, INF = 1e9 + 5, mod = 1e9 + 7, LOG = 22, SQ = 500;

ll n;

bool out(pair<ll, ll> pt, ld r) {
    ld dist = pt.F * pt.F + pt.S * pt.S;
    dist = sqrt(dist);
    return (dist > r);
}

bool valid(ld m) {
    ll ret = 0;
    pair<ll, ll> cur = {0, int(m)}, nxt = {cur.F + 1, cur.S};
    while (cur.F < m) {
        while (out(nxt, m)) {
            nxt.S--;
            if (nxt.S < 0)
                break;
        }
        if (nxt.S < 0)
            break;

        ret += nxt.S;
        cur = nxt;
        nxt = {cur.F + 1, cur.S};

    }

    return (4 * ret > n);
}

void doWork() {
    cin >> n;

    ld s = 0, e = 1e5, m, ans = 1e5;

    for (int i = 0; i < 200; i++) {
        m = (s + e) / 2;

        if (valid(m)) {
            ans = m;
            e = m;
        }
        else {
            s = m;
        }
    }

    cout << fixed << setprecision(10) << (s + e) / 2;
}

signed main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
#ifndef ONLINE_JUDGE
    if (sublime) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    int tests = 1;
    if (multipleTestCases) {
        cin >> tests;
    }
    for (int tc = 1; tc <= tests; tc++) {
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 3644kb

input:

11

output:

1.41421356241.41421356241.41421356241.41421356241.41421356241.41421356241.41421356241.41421356241.41421356241.41421356241.4142135624

result:

wrong output format Expected double, but "1.41421356241.41421356241.4142...21356241.41421356241.4142135624" found