/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 15ms 400.0 KiB
#3 Accepted 16ms 556.0 KiB
#4 Accepted 11ms 540.0 KiB
#5 Accepted 21ms 540.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 484.0 KiB
#8 Accepted 1ms 352.0 KiB
#9 Accepted 54ms 536.0 KiB
#10 Accepted 53ms 544.0 KiB
#11 Accepted 1ms 540.0 KiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-12/03/2024;TIME:-20:03 pm
  BANGALDESH , SYLHET*/

#include <iostream>
#include <cmath>     ///mathematics
#include<cstdlib>    ///for std::exit(EXIT_SUCCESS)
#include <vector>    ///array
#include <regex>     ///searching_prefix_suffix
#include <algorithm> ///finding_max_min_from_array
#include <string>    ///string_manipulation
#include <numeric>   ///findin total sum of an array
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
bool square(ll num){
    ll root  = round(sqrt(num));
    return num == root*root;
}

int main() {
   int t;
   cin >> t;
   while(t--)
   {
    ll B,D;
    cin >> B ;
    vector<ll>p;
    for(ll i =1;i<=(B*B)/2;i++){
        ll c =(i*i)+(B*B);
        ll C=round(sqrt(c));
        if(square(c)){
            D = B+i+C;
            p.push_back(D);
        }
    }
    if(p.empty()){
        cout << -1 << endl;
    }else{
        auto it = max_element(p.begin(),p.end());
        cout << *it << endl;
    }
   }
   return 0;
}

Information

Submit By
Type
Submission
Problem
P1027 Right triangle
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-12 14:03:13
Judged At
2024-03-12 14:03:13
Judged By
Score
100
Total Time
54ms
Peak Memory
556.0 KiB