Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // codeforces_crok_D.cpp : Defines the entry point for the console application.
- //
- #include <iostream>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main()
- {
- vector<long long> v;
- vector<pair<long long,bool> > mas;
- for(int i=1;i*i<5*1e+3;i++)
- {
- v.push_back(i*i);
- }
- long long ans=0;
- int a,n;
- cin>>a>>n;
- for(int i=0;i<n;i++)
- {
- mas.push_back(make_pair(a+i,false));
- }
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<v.size();j++)
- {
- if((mas[i].first%v[v.size()-1-j]&&mas[i].second==false)==0)
- {
- for(long long k=1;k*mas[i].first<a+n;k++)
- {
- double temp = sqrt(double(k*mas[i].first));
- if(temp==floor(temp))
- {
- ans+=1;
- mas[k*mas[i].first-a].second=true;
- }
- else if(sqrt(double(k))==floor(double(k))&&sqrt(double(k))>sqrt(double(v[v.size()-1-j])))
- {
- ans+=sqrt(double(v[v.size()-1-j]));
- mas[k*mas[i].first-a].second=true;
- }
- else
- {
- mas[k*mas[i].first-a].second=true;
- ans+=(k*mas[i].first)/v[v.size()-1-j];
- }
- }
- break;
- }
- }
- }
- cout<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment