QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501252#5152. Circular Caramel CookieOriginal3080upWA 0ms3856kbC++172.1kb2024-08-02 16:04:072024-08-02 16:04:07

Judging History

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

  • [2024-08-02 16:04:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-08-02 16:04:07]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int check1(int mid)
{
    int res= mid* (mid+4);
    if(n>res) return 1;
    else return 0;
}
int check2(int mid)
{
    int res= mid*mid;
    if(n>res) return 1;
    else return 0;
}
int check3(int mid)
{
    int res= mid*(mid+1);
    if(n>res) return 1;
    else return 0;
}
bool cmp(pair<int,pair <int ,int >> a,pair<int,pair <int ,int > > b)
{

    if(a.second.first==  b.second.first)
    return a.second.second < b.second.second;
    else return a.second.first < b.second.first;
}
signed main()
{
    
    cin>>n;
    int l=0,r=1e5;
    while(l+1<r)
    {
        int mid=l+r>>1;
        if(check1(mid)) l=mid;
        else r=mid;
    }
    //cout<<l <<' '<<r<<endl;
    int nowl=l,nowr=r;
    l=0,r=1e5;
    while(l+1<r)
    {
        int mid=l+r>>1;
        if(check2(mid))  l=mid;
        else r=mid;
    }
    int nxtl=l,nxtr=r;
    l=0,r=1e5;
    while(l+1<r)
    {
        int mid=l+r>>1;
        if(check3(mid)) l=mid;
        else r=mid;
    }
    int snowl=l,snowr=r;
    vector < pair<int, pair< int ,int > > > vec;
    int nowl1,nowr1,nxtl1,nxtr1,snowl1,snowr1;
    nowl1= nowl*(nowl+4);
    nowr1=nowr*(nowr+4);
    nxtl1 = nxtl*nxtl;
    nxtr1 = nxtr *nxtr;
    snowl1= snowl *(snowl+1);
    snowr1= snowr *(snowr+1);
    vec.push_back({nowl,{nowl1,1}});
    vec.push_back({nowr,{nowr1,1}});
    vec.push_back({nxtl,{nxtl1,2}});
    vec.push_back({nxtr,{nxtr1,2}});
    vec.push_back({snowl,{snowl1,3}});
    vec.push_back({snowr,{snowr1,3}});
    sort(vec.begin(),vec.end(),cmp);
    double ans=vec[3].first;
    double anss;
    int ops=vec[3].second.second;
    //cout<<nowl1<<' '<<nowr1<<' '<<nxtl1 << ' '<<nxtr1 <<' '<<snowl1<<' '<<snowr1<<endl;
    if(ops == 1)
    {
        anss=sqrt(ans*ans/4+(ans/2+1)*(ans/2+1));
    }else if(ops == 2)
    {
        
        anss= sqrt(2)*ans/2;
    }else 
    {
        anss = sqrt((ans/2)*(ans/2)+((ans+1)/2)*((ans+1)/2));
    }
    cout << fixed << setprecision(10) << anss << endl;   

    return 0;


}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

input:

11

output:

2.2360679775

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

59

output:

5.0000000000

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3856kb

input:

1

output:

0.7071067812

result:

wrong answer 1st numbers differ - expected: '1.4142136', found: '0.7071068', error = '0.5000000'