I have 2 codes.One of them shows no stdout response(with large inputs) while the other works just fine.
code 1
#define lli long long int
using namespace std;
int main()
{
lli n,a,b,k,app,chf;
app=0,chf=0;
cin>>n>>a>>b>>k;
for(lli j=1;j<=n;j++)
{
if(j%a==0){if(j%b!=0)app++;}
}
for(lli int j=1;j<=n;j++)
{
if(j%b==0){if(j%a!=0)chf++;}
}
cout<<app+chf;
}
code 2
long long int n, a, b, k;
std::cin >> n >> a >> b >> k;
long long int na = n / a;
long long int nb = n / b;
long long int nab = n / (a * b);
/*
if (na + nb - 2 * nab >= k)
std::cout << "Win\n";
else
std::cout << "Lose\n";*/
std::cout<<(na+nb-2*nab);
The result on the 1st code doesn't arrive even if I wait for sufficently long time.Even if the code is really slow ,why doesn't the output arrive(even though late).