Cod sursa(job #2695123)

Utilizator George732George George732 Data 11 ianuarie 2021 20:57:59
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.07 kb
#include <iostream>
#include <vector>
#include <fstream>
//#include "A:\Programming_languages\C++\BasicUtils\BasicUtils\Utils.h";
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int>>

int gcd(int a, int b)
{
	int ti;
	while (a != 0)
	{
		ti = a;
		a = b % a;
		b = ti;
	}
	return b;
}
int FractiiSlow(long long n)
{
	int count = (int)n;
	for (int k = 2; k <= n; k++)
		for (int b = 1; b <= n; b++)
			if (gcd(b, k) != 1)
				count++;
	return count;
}
void FractiiSlowDebug(long long n)
{
	int count = (int)n;
	for (int k = 2; k <= n; k++)
	{
		for (int b = 1; b <= n; b++)
		{
			if (gcd(b, k) != 1)
			{
				cout << "[" << b << "/" << k << "]\t";
			}
			else
			{
				cout << b << "/" << k << "\t";
				count++;
			}
		}
		cout << "\n";
	}
	cout << "\n" << "Final count: " << count << endl;
}
int main()
{
	int ti;
	ifstream input("fractii.in", std::ios::in);
	input >> ti;
	ofstream output("fractii.out", std::ios::out);

	output << FractiiSlow(ti);

	input.close();
	output.close();
	return 0;
}