QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501303#5152. Circular Caramel CookieOriginal3080upWA 0ms3856kbC++172.2kb2024-08-02 16:30:162024-08-02 16:30:16

Judging History

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

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

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,nxtr;
    nxtl=l,nxtr=r;
    //cout<< " l =" <<l<<endl;
    if(l%2 == 1) nxtl--;
    if(r%2 == 1) nxtr++;
    
    // 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[2].first;
    double anss;
    int ops=vec[2].second.second;
    //cout<<nowl1<<' '<<nowr1<<' '<<nxtl1 << ' '<<nxtr1 <<endl;
    if(ops == 1)
    {
        anss=sqrt(ans*ans/4+(ans/2+1)*(ans/2+1));
    }else if(ops == 2)
    {
        
        anss= sqrt(2)*ans/2;
    }
    //if(n == 1) cout<<1.4142135624<<endl;
    cout << fixed << setprecision(10) << anss << endl;   
    
    return 0;


}

详细

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: 3780kb

input:

59

output:

5.0000000000

result:

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

Test #3:

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

input:

1

output:

1.4142135624

result:

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

Test #4:

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

input:

2

output:

1.4142135624

result:

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

Test #5:

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

input:

3

output:

1.4142135624

result:

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

Test #6:

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

input:

4

output:

1.4142135624

result:

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