文章
11
粉丝
20
获赞
4
访问
8.3k
#include<stdio.h>
unsigned gcd(unsigned a, unsigned b){
//默认a>b
if(b == 0) return a;
else return gcd(b, a%b);
}
int main(){
int n;
unsigned a, mina, maxa;
scanf("%d%u", &n, &a);
mina = maxa = a;
for(int i = 1; i < n; i++){
scanf("%u", &a);
if(a < mina) mina = a;
if(a > maxa) maxa = a;
}
printf("%u %u %u", mina, maxa, gcd(maxa, mina));
}
登录后发布评论
暂无评论,来抢沙发