/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 1ms 328.0 KiB
#3 Accepted 1ms 332.0 KiB
#4 Accepted 1ms 284.0 KiB
#5 Accepted 1ms 364.0 KiB
#6 Accepted 1ms 328.0 KiB
#7 Accepted 1ms 284.0 KiB
#8 Accepted 1ms 432.0 KiB
#9 Accepted 1ms 328.0 KiB

Code

#include <stdio.h>

// Function to find the greatest common divisor
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// Function to print irreducible fraction
void printFraction(int numerator, int denominator) {
    int divisor = gcd(numerator, denominator);
    printf("%d / %d\n", numerator / divisor, denominator / divisor);
}

int main() {
    int G, A, U;

    // Input the number of games
    scanf("%d", &G);

    for (int i = 1; i <= G; i++) {
        // Input the number of achievements and unlocked achievements for each game
        scanf("%d %d", &A, &U);

        // Calculate the percentage and print irreducible fraction
        printf("Game #%d: ", i);
        if (A == 0) {
            printf("0 / 1\n");  // To handle the case where no achievements are available in the game
        } else {
            printFraction(U, A);
        }
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1001 Achievement-Unlocked
Language
C99 (GCC 13.2.0)
Submit At
2023-12-31 13:05:05
Judged At
2024-11-11 03:46:48
Judged By
Score
100
Total Time
1ms
Peak Memory
432.0 KiB