/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 284.0 KiB
#2 Accepted 0ms 284.0 KiB
#3 Accepted 0ms 284.0 KiB
#4 Accepted 0ms 284.0 KiB
#5 Accepted 0ms 284.0 KiB
#6 Accepted 0ms 284.0 KiB
#7 Accepted 0ms 340.0 KiB
#8 Accepted 0ms 284.0 KiB
#9 Accepted 0ms 284.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
2023-12-31 13:05:05
Judged By
Score
100
Total Time
0ms
Peak Memory
340.0 KiB