diff --git a/1828B Permutation Swap/1828B.cpp b/1828B Permutation Swap/1828B.cpp new file mode 100644 index 0000000..45490a5 --- /dev/null +++ b/1828B Permutation Swap/1828B.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; +using ll = long long; + + +void solve() +{ + int n; + cin>>n; + vectorv(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<> TC; + cin.ignore(); + while (TC--) solve(); +} \ No newline at end of file