Pagini recente » Cod sursa (job #2837436) | Cod sursa (job #391757) | Cod sursa (job #1588675) | Cod sursa (job #1080160) | Cod sursa (job #2913161)
#include <iostream>
#include <fstream>
#include <cmath>
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;
countFractii = number;
countFractii += trunc(number * number / 4);
int tempNumber = number;
if (number % 2 == 0) tempNumber = number - 2;
else tempNumber = number - 1;
countFractii += ceil((long double)number * 2 / 3) * tempNumber / 2;
fileOut << countFractii;
fileIn.close(); fileOut.close();
}
private:
unsigned long long int number{0};
unsigned long long int countFractii = 0;
};
int main()
{
Solution s;
s.rezolvare("fractii.in", "fractii.out");
return 0;
}