Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
bool sq(int hysq)
{
if(ceil(sqrt(hysq))==floor(sqrt(hysq))){
return true;
}
else{return false;}
}
void sir()
{
int b;
cin>>b;
int hi, hysq;
int para = 0;
for(hi=1; hi<= b*b/2; hi++)
{
hysq = hi*hi + b*b;
if(sq(hysq)){
para = max(para, (hi + b + int(sqrt(hysq))));
}
}
if(para != 0)
{
cout<<para<<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:17:10
- Judged At
- 2024-11-11 03:41:01
- Judged By
- Score
- 5
- Total Time
- 27ms
- Peak Memory
- 540.0 KiB