Here is the link of the problem http://www.spoj.com/problems/GAME3/
#include
using namespace std;
int main()
{
unsigned long long n, ctr, a, c, d, i;
int t;
char x[15] = { ‘m’, ‘i’, ‘m’, ‘m’, ‘i’, ‘m’, ‘i’, ‘i’, ‘m’, ‘i’, ‘m’, ‘i’, ‘m’, ‘i’, ‘m’ };
cin >> t;
while (t--)
{
cin >> n;
a = (n-2) / 15;
c = n-a*15;
if (x[c-2] == 'm')
cout << "Marica\n";
else
cout << "Ivica\n";
}
return 0;
}