Skip to content

Instantly share code, notes, and snippets.

@fardinabir
Created October 2, 2019 10:33
Show Gist options
  • Save fardinabir/7380f80b1d7f5dbeca5af02124acd706 to your computer and use it in GitHub Desktop.
Save fardinabir/7380f80b1d7f5dbeca5af02124acd706 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[10000];
int main()
{
ll i,j,k,n,t,id=0,dif=0,g=0;
while(cin>>k)
{
id=0;
if(!k)
return 0;
g=0;
arr[id++]=k;
while(cin>>k)
{
if(!k)
break;
dif=(k-arr[id-1]);
arr[id++]=k;
g=__gcd(g,dif);
}
g=g<0?g*-1:g;
printf("%lld\n",g);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment