/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 324.0 KiB
#2 Wrong Answer 0ms 388.0 KiB

Code

#include <stdio.h>

int find_triangle_perimeter(int base) {
    if (base % 2 == 0) {
        // If base is even, the other sides can be base/2 and hypotenuse = base/2 + 1
        int height = base / 2;
        int hypotenuse = height + 1;
        return base + height + hypotenuse;
    } else {
        // If base is odd, the other sides can be (base-1)/2, (base+1)/2, and hypotenuse = (base+1)/2
        int height = (base - 1) / 2;
        int hypotenuse = (base + 1) / 2;
        return base + height + hypotenuse;
    }
}

int main() {
    int T, B;
    scanf("%d", &T);

    for (int i = 0; i < T; i++) {
        scanf("%d", &B);
        int perimeter = find_triangle_perimeter(B);
        printf("%d\n", perimeter);
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1027 Right triangle
Contest
Brain booster #2
Language
C99 (GCC 13.2.0)
Submit At
2024-03-06 16:56:50
Judged At
2024-11-11 03:41:09
Judged By
Score
0
Total Time
1ms
Peak Memory
388.0 KiB