Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
  6. #define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
  7. #define file ""
  8. #define pb push_back
  9. #define F first
  10. #define S second
  11. #define _bits __builtin_popcount
  12.  
  13. typedef long long ll;    
  14. typedef double ld;
  15. typedef pair <ld, ld> PII;
  16.  
  17. const int N = 1e4 + 1;
  18. const int INF = 1e9 + 9;
  19. const int B = 1e9 + 7;
  20.  
  21. ld x;          
  22. int n, f, l[N];
  23. vector <int> v[N], t;                      
  24.  
  25. int main() {
  26. #ifdef machine42
  27.     freopen(file"in", "r", stdin);
  28.     freopen(file"out", "w", stdout);
  29. #endif
  30.     ios_base :: sync_with_stdio (0);
  31.     cin.tie(0);
  32.  
  33.     cin >> x >> n;
  34.     int ans = 0;
  35.     forn(i, 2, n) {
  36.         l[i] = min(i - 1, int(x * i));
  37.         int k = i;
  38.         for (int j = 2; j * j <= k; ++j) {
  39.             if (k % j == 0) v[i].pb(j);
  40.             while (k % j == 0) k /= j;
  41.         }  
  42.         if (k > 1) v[i].pb(k);
  43.         if (l[i] >= 1) ++ans;
  44.     }      
  45.     forn(i, 2, n) {    
  46.         forn(j, 2, l[i]) {    
  47.             f = 0;
  48.             for (auto x : v[i]) {
  49.                 if (j % x == 0) {
  50.                     f = 1;
  51.                     break;
  52.                 }
  53.             }  
  54.             if (!f) ++ans;
  55.         }
  56.     }          
  57.     cout << ans << "\n";
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement