Cod sursa(job #2913156)

Utilizator silvian.gSilvian Gulica silvian.g Data 13 iulie 2022 03:34:32
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
using namespace std;


class Solution {
public:
    void rezolvare (string fileInput, string fileOutput){
        ifstream fileIn; fileIn.open(fileInput, ios::in);
        ofstream fileOut; fileOut.open(fileOutput, ios::out);

        // From here we start the problem.
        fileIn >> number;
        
        for (int i = 1; i <= number; i++) {
            for (int j = 1; j <= number; j++) {
                if (!Map[(double)i/j])  Map.insert(pair<double, bool>((double)i/j, true));
            }
        }

        countFractii = Map.size();

        fileOut << countFractii;
        fileIn.close(); fileOut.close();
    }

private:
    int number{0};
    map<double, bool> Map;
    int countFractii = 0;
};

int main()
{
    Solution s;
    s.rezolvare("fractii.in", "fractii.out");
    return 0;
}