prestige

codeforces_croc_D

Apr 3rd, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. // codeforces_crok_D.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <cmath>
  7. using namespace std;
  8. int main()
  9. {
  10. vector<long long> v;
  11. vector<pair<long long,bool> > mas;
  12. for(int i=1;i*i<5*1e+3;i++)
  13. {
  14. v.push_back(i*i);
  15. }
  16. long long ans=0;
  17. int a,n;
  18. cin>>a>>n;
  19. for(int i=0;i<n;i++)
  20. {
  21. mas.push_back(make_pair(a+i,false));
  22. }
  23. for(int i=0;i<n;i++)
  24. {
  25. for(int j=0;j<v.size();j++)
  26. {
  27. if((mas[i].first%v[v.size()-1-j]&&mas[i].second==false)==0)
  28. {
  29. for(long long k=1;k*mas[i].first<a+n;k++)
  30. {
  31. double temp = sqrt(double(k*mas[i].first));
  32. if(temp==floor(temp))
  33. {
  34. ans+=1;
  35. mas[k*mas[i].first-a].second=true;
  36. }
  37. else if(sqrt(double(k))==floor(double(k))&&sqrt(double(k))>sqrt(double(v[v.size()-1-j])))
  38. {
  39. ans+=sqrt(double(v[v.size()-1-j]));
  40. mas[k*mas[i].first-a].second=true;
  41. }
  42. else
  43. {
  44. mas[k*mas[i].first-a].second=true;
  45. ans+=(k*mas[i].first)/v[v.size()-1-j];
  46. }
  47. }
  48. break;
  49. }
  50. }
  51. }
  52. cout<<ans;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment