#include <stdio.h>
long int coll[10001]={0};
int main()
{
long int z, i, m, l, p, f, next, s, cas=1;
while (scanf("%ld %ld %ld %ld",&z,&i,&m,&l)==4)
{
p=0;
f=0;
if (z==0 && i==0 && m==0 && l==0)
break;
/***MAIN CODE***/
while (1)
{
next = ((z*l)+i)%m;
for (s=0 ; s<p ; s++)
{
if (coll[s]==next)
{
f=1;
break;
}
}
if (f) break;
coll[p++]=next;
l=next;
}
printf("Case %ld: %ld\n",cas++,p);
}
return 0;
}
Friday, September 03, 2010
[UVa] 350 - Pseudo Random Numbers
Straightforward and simulation.
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Install MinGW GCC Port on Windows. 1. Just go to this address [ http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ ]...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.