AT消費量検証用
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
long SEED0=0x3ca2; // 川崎ロッカー
long seed;
int dq9rand(){seed=seed*1103515245+12345;return (int)((seed
>>16)&0x7FFF);}
void skip(int n){while(n-->0) dq9rand();}
int main(int argc,char **argv){
int i,j, buf[12][10],idx[12],mem[60];
int chk[12];
int searchLast=1000;
chk[0]=-1;
i=1;
if( argc>1 && strnicmp(argv[i],"/S=",3)==0 ) SEED0=strtol(argv[i++],0,16),argc--;
if( argc>1 && strnicmp(argv[i],"/n=",3)==0 ) searchLast=atol(argv[i++]),argc--;
if( argc>1 ){
char *p=argv[1];
for( i=0; i<12; i++ ){
if( *p==',' ) p++;
if( *p==0 ) break;
sscanf(p,"%d%n,",&chk[i],&j);p+=j;
}
if( i<12 ){ printf("arg ERROR\n");return 1;}
}
for(int nSkip=0;nSkip<searchLast;nSkip++ ){
seed=SEED0;skip(nSkip);
for(i=0;i<12;i++) for(j=0;j<10;j++) buf[i][j]=-1;
for(i=0;i<12;i++) idx[i]=0;
for(i=0;i<60;i++){
j=dq9rand()%12;
while(idx[j]>=10) j=(j+1)%12;
buf[j][idx[j]++]=i;mem[i]=j;
}
for(i=0;i<12;i++) if( chk[i]!=idx[i] ){ i=-1;break;}
if( i>0 ){
printf("\n===== SEED=0x%04X nSkip=%d =====\n",SEED0,nSkip);
for(j=9;j>=0;j--){
for(i=0;i<12;i++) printf((buf[i][j]<0)?" ":" (%2d)",buf[i][j]);
printf("\n");
}
}
if( chk[0]<0 ){
for(i=0;i<12;i++) printf("%d,",idx[i]);
for(i=0;i<60;i++) printf("%d",mem[i]);
printf("\n");
}
}
return 0;
}