Cod sursa(job #2253616)

Utilizator whitewolf3131Ursu Laurentiu Cristian whitewolf3131 Data 4 octombrie 2018 10:45:46
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>
#include <string>

using namespace std;

ifstream in("fractii.in");
ofstream out("fractii.out");
int totneg=0;
bool v[1000000];
int n;
void ciur(){
    for(int i=2; i<=n; i++){
        int tour=0;
        if(!v[i]){
            for(int j=i+i; j<=n; j+=i){
                v[j]=true;
                tour++;
                totneg+=tour*2;
            }
        }
    }    
}
int main()
{
    in>>n;
    int tot=n*n;
    ciur();
    totneg+=n-1;
    out<<tot-totneg;
}