Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream in("mins.in");
- ofstream out("mins.out");
- int c,d,m;
- short a[1000001];
- long long r;
- bool ok[1000001];
- int main()
- { in>>c>>d;
- c--,d--;
- m=min(c,d);
- for(int i=1;i<=m;i++)
- a[i]=1;
- for(int i=2;i<=m;i++)
- if(!ok[i])
- for(int j=i;j<=m;j+=i)
- a[j]*=-1,ok[j]=1;
- for(int i=2;i*i<=m;i++)
- for(int j=1;i*i*j<=m;j++)
- a[i*i*j]=0;
- r=1LL*c*d;
- for(int i=2;i<=m;i++)
- r+=1LL*a[i]*(c/i)*(d/i);
- out<<r;
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement