Here you will find solutions of many problems on spoj. If you want solution of some problem which is not listed in blog or have doubt regarding any spoj problem (which i have solved) or any programming concept (data structure) you can mail me @ raj.nishant360@gmail.com
And my humble request to you all that don't copy the code only try to understand the logic and algorithm behind the code. I have started this because if you tried as hard as you can and still can't find any solution to the problem then you can refer to this.
You can read my answer how to start competitive programming CLICK HERE

Tuesday, March 11, 2014

BTCD14A-Game of Pips

Game of Pips

below given code is for btcd14a spoj or Game of Pips spoj
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
long long GCD(long long a,long long b)
{
 return b==0?a:GCD(b,a%b);
}
int main()
{
 int n;
 scanf("%d",&n);
 long long a[n+9],k;
 scanf("%lld",&a[0]);
 int i;
 k=a[0];
 for(i=1;i<n;i++)
 {
  scanf("%lld",&a[i]);
  k=GCD(k,a[i]);
 }
 if(k%2==0)
 {
  while(k%2!=1)
   k=k/2;
  printf("%lld\n",k);
 }
 else 
  printf("%lld\n",k);
 return 0;
}