/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB

Code

#include <iostream>
#include <cmath>

// Function to calculate the greatest common divisor (GCD) using Euclidean algorithm
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// Function to simplify the fraction
void simplifyFraction(int &numerator, int &denominator) {
    int commonDivisor = gcd(numerator, denominator);
    numerator /= commonDivisor;
    denominator /= commonDivisor;
}

int main() {
    int numGames;
    std::cout << "Enter the number of games: ";
    std::cin >> numGames;

    for (int i = 0; i < numGames; ++i) {
        int achievementsAvailable, achievementsUnlocked;
        std::cout << "Enter the number of achievements available for game " << i + 1 << ": ";
        std::cin >> achievementsAvailable;

        std::cout << "Enter the number of achievements unlocked by Makorsha-Manov for game " << i + 1 << ": ";
        std::cin >> achievementsUnlocked;

        int numerator = achievementsUnlocked * 100;
        int denominator = achievementsAvailable;

        simplifyFraction(numerator, denominator);

        std::cout << "Percentage of achievements unlocked for game " << i + 1 << ": " << numerator << " / " << denominator << "\n\n";
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1001 Achievement-Unlocked
Language
C++11 (G++ 13.2.0)
Submit At
2024-03-06 13:03:45
Judged At
2024-11-11 03:42:53
Judged By
Score
0
Total Time
1ms
Peak Memory
540.0 KiB