/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 552.0 KiB
#2 Accepted 19ms 492.0 KiB
#3 Accepted 19ms 544.0 KiB
#4 Accepted 20ms 540.0 KiB
#5 Accepted 18ms 548.0 KiB
#6 Accepted 21ms 332.0 KiB
#7 Accepted 21ms 540.0 KiB
#8 Accepted 21ms 328.0 KiB
#9 Accepted 16ms 540.0 KiB
#10 Accepted 15ms 540.0 KiB
#11 Accepted 21ms 544.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
// special case 1009
// Cmax =  floor((B^2)/2)+1;

void solve2()
{
    ll B,h,H,sqH,ans,hh,BB; cin>>B;
    BB = B*B;
    for(ll h=1;h<=10000000;h++)
    {
        hh = h*h;
        H = BB+hh;
        sqH = sqrt(H);
        if(sqH*sqH==H)
        {
            cout<<"base = "<<B<<endl;
            cout<<"hight= "<<h<<endl;
            cout<<"hypo = "<<sqH<<endl;
            cout<<endl;
        }
    }
}

//ofstream file("output0.txt");
void solve()
{
    ll B,h,H,sqH,ans,hh,sqB; cin>>B;
    sqB = B*B;
    ll limit = (sqB/2)+5;
    ans=-1;
   // for(ll h=limit;h>=1;h--)
    for(ll h=1000000;h>=1;h--) //timeout
    {
        sqH = sqB+h*h;
        H = sqrt(sqH);
        if(H*H==sqH)
        {
            ans=H+B+h;
            break;
        }
    }
    cout<<ans<<endl;
    //file<<ans<<endl;
}
int main()
{
    
    int t; cin>>t; while(t--) solve();
   // file.close();
}

Information

Submit By
Type
Submission
Problem
P1027 Right triangle
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-05 03:54:56
Judged At
2024-03-05 03:54:56
Judged By
Score
100
Total Time
21ms
Peak Memory
552.0 KiB