Cod sursa(job #2772604)

Utilizator noonex64U dont need to know noonex64 Data 1 septembrie 2021 19:33:42
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
using namespace std;
ifstream in("flip.in");
ofstream out("flip.out");
int main() {
	int n;
	in>>n;
	int total=1;
	for(int i=2;i<=n;i++) {
	    int d=2, cp=i, dummy=1;
	    while(cp!=1) {
	        int p=1;
	        while(cp%d==0) {
	            cp/=d;
	            p*=d;
	        }
	        dummy*=(p-p/d);
	        d++;
	        if(d*d>cp)
	            d=cp;
	    }
	    total+=2*dummy;
	}
	out<<total;
}