Pagini recente » Cod sursa (job #1033470) | Cod sursa (job #41502) | Cod sursa (job #2989776) | Cod sursa (job #1230680) | Cod sursa (job #2871864)
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
ifstream fin ("mins.in");
ofstream fout ("mins.out");
const int LIMIT = 1e6;
bitset <LIMIT + 5> ciur;
int phi[LIMIT + 5];
void update(int x){
for(int i=2*x; i<=LIMIT; i+=i){
ciur[i] = true;
phi[i] -= phi[i] / x;
}
}
int c, d;
long long sol;
signed main (){
ios_base::sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
for(int i=1; i<=LIMIT; i++)
phi[i] = i;
ciur[0] = ciur[1] = true;
update(2);
update(3);
for(int i=5; i<=LIMIT; i+=6){
if(!ciur[ i ]) update( i );
if(!ciur[i+2]) update(i+2);
}
fin>>c>>d;
for(int i=1; i < max(c, d); i++)
sol += phi[i];
fout<<sol - 1;
return 0;
}