Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
bool sq(int hysq)
{
return(ceil(sqrt(hysq))==floor(sqrt(hysq)));
}
void sir()
{
int b;
cin>>b;
int hi, hysq;
int max_peri = -1;
int n = ceil((b*b)/2) ;
for(hi=n; hi>=1; hi--)
{
int hysq = hi*hi + b*b;
if (sq(hysq)) {
int peri = hi + b + static_cast<int>(sqrt(hysq));
max_peri = max(max_peri, peri);
}
}
if(max_peri != -1)
{
cout<<max_peri<<endl;
}
else{cout<<"-1"<<endl;}
}
int main()
{
int t;
cin>>t;
while(t--)
{
sir();
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1027 Right triangle
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-03-12 09:57:39
- Judged At
- 2024-11-11 03:41:01
- Judged By
- Score
- 5
- Total Time
- 17ms
- Peak Memory
- 532.0 KiB