G16 裴蜀定理
视频链接:https://www.bilibili.com/video/BV1bW4y1e7n9/
#include<iostream> #include<cmath> using namespace std; int n,a,s; int gcd(int a, int b){ return b==0?a:gcd(b,a%b); } int main(){ cin >> n; for(int i=1;i<=n;i++){ cin >> a; s = gcd(s,abs(a)); } cout << s; return 0; }