Help me in solving LEDIV problem

My issue

my sevie() is causing runtime error what is the problem with this

My code

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define vb vector<bool>
#define vi vector<int>

vb isprime(1e6+1,1);
vi smallprimefact(1e6+1,1e9);

void seive()
{
    isprime[0]=isprime[1]=0;
    isprime[2]=1;
    for(int i=2;i<=1e6;i++)
    {
        if(!isprime[i])continue;
        smallprimefact[i]=i;
        for(int j=i*i;j<=1e6;j=j+i)
        {
            isprime[j]=0;
            smallprimefact[j]=min(smallprimefact[j],i);
        }
    }
}

int main() {
	// your code goes here
	seive();
	cout<<isprime[1166];
	
}

Learning course: Number theory
Problem Link: Little Elephant and Divisors Practice Problem in Number theory - CodeChef

When initializing j=i*i , the value can exceed the maximum int can accommodate.

1 Like

so i need to make it ll . thanks