QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501313#5152. Circular Caramel CookieEdisonBaTL 327ms3940kbC++141.5kb2024-08-02 16:39:012024-08-02 16:39:02

Judging History

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

  • [2024-08-02 16:39:02]
  • 评测
  • 测评结果:TL
  • 用时:327ms
  • 内存:3940kb
  • [2024-08-02 16:39:01]
  • 提交

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;
    ++n;
    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: 324ms
memory: 3800kb

input:

11

output:

2.2360679793

result:

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

Test #2:

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

input:

59

output:

5.0000000044

result:

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

Test #3:

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

input:

1

output:

1.4142135626

result:

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

Test #4:

score: 0
Accepted
time: 327ms
memory: 3940kb

input:

2

output:

1.4142135626

result:

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

Test #5:

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

input:

3

output:

1.4142135626

result:

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

Test #6:

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

input:

4

output:

2.2360679793

result:

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

Test #7:

score: -100
Time Limit Exceeded

input:

1000000000

output:


result: