Uva 408 – Uniform Generator
/*
Uva 408 – Uniform Generator
Verdict : Accepted
Time : 0.053
I have seen everyone try to do it use array or vector. But I Did not use
that type. Just keep track on your cycle and then count it. If the
count is equal to the mod then it will be a Good Choice otherwise Bad
Choice.
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#define sf scanf
#define pf printf
#define sfint scanf (“%d %d”,&a,&b)
#define sfl scanf (“%ld %ld”,&a,&b)
#define sfll scanf (“%lld %lld”,&a,&b)
#define sfd scanf (“%lf %lf”,&a,&b)
#define sff scanf (“%f %f”,&a,&b)
#define loop (i,n) for (i=0;i<n;i++)
#define LL long long
#define L long
#define nl puts(“”)
#define N 10000
#define MOD 10000000007
#define pb push_back
#define pi acos(-1.0)
#define sz size()
#define gc getchar ()
#define ps push
#define clr clear
#define bn begin()
#define ed end()
using namespace std;
int main()
{
L s,m;
while (2 == sf (“%ld %ld”,&s,&m))
{
L seed = 0, a = seed, count=0;
while (true)
{
seed = seed + s;
a = seed;
a%=m; count++;
if (a == 0) break;
}
if (count == m)
{
pf (“%10ld%10ld Good Choice\n\n”,s,m);
}
else
{
pf (“%10ld%10ld Bad Choice\n\n”,s,m);
}
}
return 0;
}
Comments
Post a Comment