I need to randomly produce two numbers L and R such that 1 ≤ L ≤ R ≤ 10^18. How this can be done ? Please help.
My Code :
#define MAXN 1000
int main(){
srand(time(NULL));
int x=rand()%MAXN;
int y=rand()%100000;
int z=rand()%100000;
long L =x;
long R=x*y*z;
assert(L<=R && L>=1 && L<=1000000000000000000 && R>=1 && R<=1000000000000000000);
cout<<L<<" "<<R<<"\n";
}
Obviously its not right way. So i am looking for best way to do it.
Aucun commentaire:
Enregistrer un commentaire