一个自己写的生成随机数的代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
int Random_List[10000005],Point_Number_Pos,Random_List_Size;
int Randomly_Change_Number(int x){//It's useful.
x^=0x15e2cc06f611bce5ll;
x=(x>>31)^x;
x+=0xc516a6837caaf61bll;
x=(x^(x>>26))*0x16ab06dede20b9125ll;
return (x-0x3949c48766d508bfll)^x;
}
void Make_Good_Randomly_Number(int seed,int size,int a[]){//We need a good seed.It can make some good random number.
a[0]=seed;
for(int i=1;i<=size;++i){
a[i]=Randomly_Change_Number(a[i-1]);
}
}
void init_rand(int len,int seed=1,int Random_List[]=Random_List){//It can make a randomly array.
Make_Good_Randomly_Number(seed,len,Random_List);
Random_List_Size=len;
Point_Number_Pos=0;
}
int get_rand(int l,int r,int Random_List[]=Random_List){//Get a randomly number.
if(Point_Number_Pos==Random_List_Size)Point_Number_Pos=0;
int x=Random_List[++Point_Number_Pos],mod=r-l+1;
x=(x%mod+mod)%mod;
return x+l;
}
int rand_value(int l,int r,int Value_List[],int Random_List[]=Random_List){//Get by Value.
/*
I will make this function.
Wait me sometime,please.
I will make it fastly.
And you can help me to make it.
Can you join?
*/
}
signed main(){//sample
init_rand(100);
for(int i=1;i<=20;i++){
cout<<get_rand(1,10000)<<" ";
}
return 0;
}