QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501311#5152. Circular Caramel CookieEdisonBaWA 324ms3936kbC++141.5kb2024-08-02 16:37:362024-08-02 16:37:36

Judging History

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

  • [2024-08-02 16:37:36]
  • 评测
  • 测评结果:WA
  • 用时:324ms
  • 内存:3936kb
  • [2024-08-02 16:37:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ld long double
typedef long long ll;
#define re read()
#define INF 9223372036854775800
#define fr(i, x, y) for(int i = x, p = y; i <= p; ++i) 
#define rp(i, x, y) for(int i = x, p = y; i >= p; --i)
#define Timeok ((double)clock() / CLOCKS_PER_SEC < MAX_TIME)
const double MAX_TIME = 1.0 - 0.0032;

inline ll read()
{
   ll x = 0, f = 0;
   char ch = getchar();
   while (!isdigit(ch))
      f |= (ch == '-'), ch = getchar();
   while (isdigit(ch))
      x = (x << 1) + (x << 3) + (ch ^= 48), ch = getchar();
   return f ? -x : x;
}

void write(ll x)
{
   if (x < 0)
      putchar('-'), x = -x;
   if (x > 9)
      write(x / 10);
   putchar(x % 10 + 48);
}

inline void W(ll x, char ch)
{
    write(x);
    putchar(ch);
}

/*------------C-O-D-E------------*/

const int N = 1e5 + 4;
ll n, m, T;

ld ju(ll x, ll y)
{
    return (ld)sqrt(x*x+y*y);
}

bool Check(ld r)
{
    ll ans = 0;
    fr(i, 1, r)
    {
        rp(j, r, 1)
        {
            if(ju(i, j) <= r + 0.000000001) {
                ans += 4 * j;
                break;
            }
        }
    }
    return ans >= n;
}

int main()
{
    n = re;
    ld l = 0.0, r = 50000.0, eps = 1e-8;
    ld mid;
    while(r - l > eps)
    {
        mid = (l + r) / 2.0;
        if(Check(mid))
        {
            r = mid;
        }
        else l = mid;
    }
    printf("%.10Lf\n", mid);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 323ms
memory: 3728kb

input:

11

output:

2.2360679793

result:

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

Test #2:

score: 0
Accepted
time: 324ms
memory: 3936kb

input:

59

output:

5.0000000044

result:

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

Test #3:

score: 0
Accepted
time: 323ms
memory: 3872kb

input:

1

output:

1.4142135626

result:

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

Test #4:

score: 0
Accepted
time: 320ms
memory: 3860kb

input:

2

output:

1.4142135626

result:

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

Test #5:

score: 0
Accepted
time: 319ms
memory: 3872kb

input:

3

output:

1.4142135626

result:

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

Test #6:

score: -100
Wrong Answer
time: 324ms
memory: 3832kb

input:

4

output:

1.4142135626

result:

wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'