Advertisement
bappi2097

M - n-divisors

Sep 11th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. #define maxSz 10e7
  5. vector<int>divisors(maxSz);
  6. void Divisor(int n)
  7. {
  8.     for(int i=1;i<=n;i++)for(int j=i;j<=n;j+=i)divisors[j]++;
  9.     return;
  10. }
  11. int main()
  12. {
  13.     ios_base::sync_with_stdio(false);
  14.     cin.tie(NULL);
  15.     #ifndef ONLINE_JUDGE
  16.     freopen("input.cpp","r",stdin);
  17.     //freopen("output.cpp","w",stdout);
  18.     #endif // ONLINE_JUDGE
  19.     ll a,b,n,cnt=0;
  20.     cin>>a>>b>>n;
  21.     if(a>b)swap(a,b);
  22.     Divisor(b);
  23.     for(int i=a;i<=b;i++)if(divisors[i]==n)cnt++;
  24.     cout<<cnt<<endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement