#include
using namespace std;
#define ll long long
ll number_divisble(ll n)
{
ll ans=0;
ll dem;
ll count;
ll a[]={2,3,5,7,11,13,17,19};
for(ll i=1;i<=(1<<8)-1;i++)
{
count=0;
dem=1;
while(i!=0)
{
if(i&1)
dem*=a[count];
count++;
i=i>>1;
}
if(i&1)
ans+=(n/dem);
else
ans-=(n/dem);
}
return ans;
}
int main()
{
ll t;
cin>>t;
while(t–)
{
ll n;
cin>>n;
ll ans=number_divisble(n);
cout<<ans<<endl;
}
return 0;
}
Time limit excedded?
share code in cb ide
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.