Pagini recente » Cod sursa (job #56250) | Cod sursa (job #2758275) | Cod sursa (job #2434284) | Cod sursa (job #2794287) | Cod sursa (job #3220507)
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const int Vmax = 1000001;
int c, d;
bool bad[Vmax];
int cnt[Vmax];
int main(){
ifstream fin("mins.in");
ofstream fout("mins.out");
fin>>c>>d;
c--;
d--;
long long sol=1LL*c*d;
for(int k=2;k<=min(c, d);k++){
if(cnt[k]==0){
for(int j=k;j<=min(c, d);j+=k)
cnt[j]++;
if(k<46349)
for(int o=k*k;o<=min(c, d);o+=k*k){
cout<<k<<" ";
bad[o]=1;
}
}
}
for(int k=2;k<=min(c, d);k++){
if(bad[k])
continue;
if(cnt[k]%2){
sol-=1LL*((c/k)*(d/k));
}
else
sol+=1LL*((c/k)*(d/k));
}
fout<<sol;
}