/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Accepted 10ms 532.0 KiB
#3 Accepted 11ms 536.0 KiB
#4 Accepted 8ms 764.0 KiB
#5 Accepted 14ms 764.0 KiB
#6 Accepted 1ms 320.0 KiB
#7 Accepted 1ms 552.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 34ms 532.0 KiB
#10 Accepted 33ms 544.0 KiB
#11 Accepted 1ms 324.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-11-11 03:40:56
Judged By
Score
100
Total Time
34ms
Peak Memory
764.0 KiB