voidUncompress(FILE *infile, FILE *outfile){int N, M, L, now, A, B, Q, tmp, i;char type =getc(infile);fscanf(infile,"%d%d%d",&N,&M,&L);fscanf(infile,"%d%d%d%d",&now,&A,&B,&Q);fprintf(outfile,"%c%d\n", type, N);for(i =1; i <= N; i ++){
now =(now * A + B)% Q, tmp = now %10000;
now =(now * A + B)% Q;if(now *2< Q) tmp *=-1;if(i < N)fprintf(outfile,"%d", tmp);elsefprintf(outfile,"%d\n", tmp);}for(i =1; i < N; i ++){
now =(now * A + B)% Q;
tmp =(i < L)? i : L;fprintf(outfile,"%d%d\n", i - now % tmp, i +1);}for(i =1; i < M; i ++){
now =(now * A + B)% Q;if(now *3< Q){
now =(now * A + B)% Q;fprintf(outfile,"Query %d\n", now % N +1);}else{
now =(now * A + B)% Q, tmp = now %10000;
now =(now * A + B)% Q;if(now *2< Q) tmp *=-1;
now =(now * A + B)% Q;fprintf(outfile,"Change %d%d\n", now % N +1, tmp);}}fprintf(outfile,"Done\n");}
Pascal 版本:
procedure Uncompress(var infile, outfile : text);
var N, M, L, now, A, B, Q, tmp, i : longint;
ch : char;
begin read(infile, ch, N, M, L, now, A, B, Q);
writeln(outfile, ch, ' ', N);
for i := 1 to N do begin
now := (now * A + B) mod Q;
tmp := now mod 10000;
now := (now * A + B) mod Q;
if now * 2 < Q then tmp := -tmp;
if i < n then write(outfile, tmp, ' ')
else writeln(outfile, tmp);
end;
for i := 1 to N - 1 do begin
now := (now * A + B) mod Q;
if i < L then tmp := i
else tmp := L;
writeln(outfile, i - now mod tmp, ' ', i + 1);
end;
for i := 1 to M - 1 do begin
now := (now * A + B) mod Q;
if now * 3 < Q then begin
now := (now * A + B) mod Q;
writeln(outfile, 'Query ', now mod N + 1);
end
else begin
now := (now * A + B) mod Q;
tmp := now mod 10000;
now := (now * A + B) mod Q;
if now * 2 < Q then tmp := -tmp;
now := (now * A + B) mod Q;
writeln(outfile, 'Change ', now mod N + 1, ' ', tmp);
end;
end;
writeln(outfile, 'Done');
end;