Pagini recente » Cod sursa (job #2481005) | Cod sursa (job #2285176) | Cod sursa (job #1712114) | Cod sursa (job #1533433) | Cod sursa (job #2913156)
#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;
}