/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 18ms 360.0 KiB
#3 Accepted 18ms 356.0 KiB
#4 Accepted 12ms 328.0 KiB
#5 Accepted 22ms 492.0 KiB
#6 Accepted 2ms 552.0 KiB
#7 Accepted 2ms 484.0 KiB
#8 Accepted 2ms 484.0 KiB
#9 Accepted 55ms 532.0 KiB
#10 Accepted 54ms 536.0 KiB
#11 Accepted 2ms 328.0 KiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-12/03/2024;TIME:-16:10 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:02:08
Judged At
2024-11-11 03:40:56
Judged By
Score
100
Total Time
55ms
Peak Memory
552.0 KiB