41 lines
681 B
Text
41 lines
681 B
Text
define MOD = 1_000_000_000;
|
|
int State(55), SI, SJ;
|
|
|
|
ffunc Subrand;
|
|
|
|
proc SubrandSeed(P1);
|
|
int P1;
|
|
int P2, I, J;
|
|
[P2:= 1;
|
|
State(0):= rem(P1 / MOD);
|
|
J:= 21;
|
|
for I:= 1 to 55-1 do
|
|
[if J >= 55 then J:= J - 55;
|
|
State(J):= P2;
|
|
P2:= P1 - P2;
|
|
if P2 < 0 then P2:= P2 + MOD;
|
|
P1:= State(J);
|
|
J:= J + 21;
|
|
];
|
|
SI:= 0;
|
|
SJ:= 24;
|
|
for I:= 0 to 165-1 do Subrand;
|
|
];
|
|
|
|
func Subrand;
|
|
int X;
|
|
[if SI = SJ then SubrandSeed(0);
|
|
SI:= if SI then SI-1 else 54;
|
|
SJ:= if SJ then SJ-1 else 54;
|
|
X:= State(SI) - State(SJ);
|
|
if X < 0 then X:= X + MOD;
|
|
State(SI):= X;
|
|
return X;
|
|
];
|
|
|
|
int I;
|
|
[SI:= 0; SJ:= 0;
|
|
SubrandSeed(292929);
|
|
for I:= 0 to 10-1 do
|
|
[IntOut(0, Subrand); CrLf(0)];
|
|
]
|