From eafe2662e1a94da10fd529625d4ca35a067127a5 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Fri, 14 Jul 2023 17:36:06 +0600 Subject: [PATCH] initial commit --- 1828B Permutation Swap/1828B.cpp | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 1828B Permutation Swap/1828B.cpp 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