UVA 350 - Pseudo-Random Numbers

Problem PDF

Solution:

/*************************************
******** Team : BUBT_HIDDEN **********
**************************************
*********** Shipu Ahamed *************
*************************************/

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define sc scanf
#define pf printf
#define ll long long
#define pi 2*acos(0.0)

#define ff first
#define se second
#define inf (1<<30)                                              //infinity value
#define pb push_back
#define mod  1000000007
#define ST(v) sort(v.begin(),v.end())
#define cover(a,d) memset(a,d,sizeof(a))
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define un(v) ST(v), v.erase(unique(v.begin(),v.end()),v.end())

using namespace std;
ll Z,I,M;

int main()
{
    ll L,no=0;
    while(cin>>Z>>I>>M>>L)
    {
        if(Z==0&&I==0&&M==0&&L==0) break;
        ll same,c=0;
        mapmp;
        while(1)
        {
            same=((Z*L)+I)%M;
            mp[same]++;
            if(mp[same]==2) break;
            L=same;
            c++;
        }
        pf("Case %lld: %lld\n",++no,c);
    }
    return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/350/350.cpp