/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 392.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 1ms 532.0 KiB

Code

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main() {
    int T;
    std::cin >> T;
    for(int i = 0; i < T; i++) {
        int n;
        std::cin >> n;
        std::vector<int> p;
        for(int j = 1; j <= 1000; j++) {
            int c = n*n + j*j;
            double C = sqrt(c);
            if(C == floor(C)) {
                int perimeter = static_cast<int>(C) + n + j;
                p.push_back(perimeter);
            }
        }
        if(p.empty()) {
            std::cout << -1 << std::endl;
        } else {
            std::cout << *max_element(p.begin(), p.end()) << std::endl;
        }
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1027 Right triangle
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-12 13:53:29
Judged At
2024-11-11 03:40:56
Judged By
Score
5
Total Time
1ms
Peak Memory
532.0 KiB