1. 程式人生 > >關於裴蜀定理。

關於裴蜀定理。

某谷模板 https://www.luogu.org/problemnew/show/P4549

百度詞條 https://baike.baidu.com/item/%E8%A3%B4%E8%9C%80%E5%AE%9A%E7%90%86

推薦部落格 http://www.cnblogs.com/aininot260/p/9477754.html

 1 #include<cstdio>
 2 #include<cmath>
 3 using namespace std;
 4 int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
 5 int n, ans;
6 int main(){ 7 scanf("%d",&n); 8 int x; 9 for(int i=1; i<=n; i++){ 10 scanf("%d",&x); 11 ans=gcd(ans,x); 12 } 13 printf("%d",abs(ans)); 14 return 0; 15 }