专栏文章
手搓随机数
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mip9xlv8
- 此快照首次捕获于
- 2025/12/03 08:33 3 个月前
- 此快照最后确认于
- 2025/12/03 08:33 3 个月前
CPP
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<chrono>
#include<cmath>
#include<queue>
#include<ctime>
#include<map>
#define intu unsigned long long
#define intt long long
#define dlel long double
#define dle double
using namespace std;
using namespace chrono;
const int Imax=0x7fffffffL;
const long long LLmax=0x7fffffffffffffffLL;
const int Mod=998244353;
const int N=1005,M=1000;
auto start=high_resolution_clock::now();
int x,y,z;
void change(int k){z=k;}
int Rand()
{
int rnd=duration_cast<microseconds>(high_resolution_clock::now()-start).count();
rnd=abs(rnd-496983);
x=rnd%Mod*rnd%Mod*rnd%Mod*7*Mod,y=rnd%Mod*1332%Mod;
z+=rnd*1237%Mod;
return abs(x+y+z)%Mod;
}
int randn=Rand();
int root=Rand()%M+1;
int tree[N];
int topturn[N];
int fa[N];
void initnxt()
{
for(int i=1;i<=M;i++) fa[i]=Rand()%M+1;
fa[root]=0;
for(int i=1;i<=M;i++)
{
int j=i;
int cnt=0;
while(fa[j])
{
cnt++;
if(cnt>M) fa[j]=root;
j=fa[j];
}
}
}
void topsort()
{
int rd[N];
memset(rd,0,sizeof(rd));
for(int i=1;i<=M;i++) rd[fa[i]]++;
int tot=0;
while(tot<M)
{
for(int i=1;i<=M;i++)
{
if(!rd[i])
{
topturn[++tot]=i;
rd[fa[i]]--;
rd[i]=1;
}
}
}
}
void moveup(){for(int i=1;i<=M;i++) tree[fa[topturn[i]]]^=tree[topturn[i]];}
void startor()
{
int beored=Rand(),p=Rand()%M+1;
while(p)
{
tree[p]|=beored;
p=fa[p];
beored^=Rand();
}
}
void startand()
{
int beanded=Rand(),p=Rand()%M+1;
while(p)
{
tree[p]&=beanded;
p=fa[p];
beanded^=Rand();
}
}
void make_randn()
{
int times=Rand()%105;
while(times--)
{
if(Rand()%2) startand();
else startor();
moveup();
}
for(int i=1;i<=M;i++)
{
if(Rand()%2) randn|=tree[i];
else randn^=tree[i];
}
randn=abs(randn);
}
void init()
{
for(int i=1;i<=100;i++)
{
initnxt();
topsort();
make_randn();
change(randn);
}
}
int main()
{
init();
for(int i=1;i<=10;i++) printf("%d\n",Rand());
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...