Inclusion and exclusion code

mam why my code is not runing,
#include
#include<math.h>
using namespace std;

int main()
{
long long int k;
cin>>k;
for(long long int l=0;l<k;l++)
{
long long int a[]={2,3,5,7,11,13,17,19};
long long int n=sizeof(a)/sizeof(int);
long long int x=pow(2,n);
long long int m;
cin>>m;
long long int sum=0;
for(int i=1;i<x;i++)
{
long long int j=0;
long long int b=1;
long long int d=i;
while(d!=0)
{
long long int x=d&1;
d=d>>1;
if(x==1)
{
b=b*a[j];
j++;
}
else{
j++;
}
}
long long int y=i&1;
long long int e=m/b;
if(y>0)
{
sum=sum-e;
}
else{
sum=sum+e;
}
}
cout<<sum<<endl;
}
return 0;
}

please share code in cb ide

mam ye raha code cb m

nhi hua save

file->save karna h
empty /invalid ide ka link aya h @YASHMATHURIA123
image

Mam ye raha code cb m

1 Like

mam maine apna code optimize bhi kar diya magar jab bhi nahi chal raha hai please help

mene to koi code provide nhi kia

mam woh mere code m odd/even ki problem thi magar mera code abhi bhi sahi karna k baad bhi time limit extended dikha raha hai

yeh code try karke dekho i dont have access to q
so cant tell if it will not give tle

mam ye toh kuch aur hi output de raha hai

sahi to the o/p for sample test case

yes mam it works sorry i put wrong input

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.