/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 6ms 532.0 KiB
#2 Accepted 21ms 764.0 KiB
#3 Accepted 21ms 320.0 KiB
#4 Accepted 22ms 324.0 KiB
#5 Accepted 20ms 548.0 KiB
#6 Accepted 24ms 764.0 KiB
#7 Accepted 24ms 536.0 KiB
#8 Accepted 23ms 324.0 KiB
#9 Accepted 18ms 532.0 KiB
#10 Accepted 17ms 768.0 KiB
#11 Accepted 24ms 764.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-11-11 03:42:54
Judged By
Score
100
Total Time
24ms
Peak Memory
768.0 KiB