initial commit

This commit is contained in:
ShazidMahsrafi 2023-07-14 17:36:06 +06:00
parent 3fe7d6afe5
commit eafe2662e1

View File

@ -0,0 +1,33 @@
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
cin>>n;
vector<int>v(n+1);
for(int i=1; i<=n; i++)
{
cin>>v[i];
}
int ans=0, diff;
for(int i=1; i<=n; ++i)
{
diff=abs(v[i]-i);
ans=__gcd(ans,diff);
}
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
cin >> TC;
cin.ignore();
while (TC--) solve();
}