博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
骚输入
阅读量:4705 次
发布时间:2019-06-10

本文共 873 字,大约阅读时间需要 2 分钟。

Maximum GCD UVA - 11827

1 #include 
2 #include
3 #include
4 using namespace std; 5 int gcd(int a,int b){ 6 return b ? gcd(b,a%b) : a; 7 } 8 int main(){ 9 int t;10 int a[105];11 char c;12 scanf("%d",&t);13 while(getchar() != '\n');14 while(t--){15 int cnt = 0;16 while((c = getchar()) != '\n'){17 if(c >= '0' && c <= '9'){18 ungetc(c,stdin);19 scanf("%d",&a[cnt++]);20 }21 }22 int maxx = 0;23 for(int i = 0; i < cnt-1; i++){24 for(int j = i+1; j < cnt; j++){25 int d = gcd(a[i],a[j]);26 if(d > maxx) maxx = d;27 }28 }29 printf("%d\n",maxx);30 }31 return 0;32 }

 

转载于:https://www.cnblogs.com/zxz666/p/10681084.html

你可能感兴趣的文章
无人工干预地自动下载某个文件
查看>>
oracle的单行函数---字符函数
查看>>
Python中的 __init__和 __new__
查看>>
css3 奇技淫巧 - 如何给小汽车换个背景色谈起
查看>>
spring源码学习1 - IDEA构建spring源码阅读环境
查看>>
C#——this关键字(2,3)(含求助贴)
查看>>
PAT1002 写出这个数 (C++实现)
查看>>
亚洲物流巨擘获中国投资者入股
查看>>
how to update product listing price sale price and sale date using mobile App
查看>>
hdu 1143
查看>>
Selenium Grid操作使用指南
查看>>
搭建hadoop集群,
查看>>
C++ —— 编译程序
查看>>
Search Binary Tree For Pre Order
查看>>
了解自己的学生,因材施教
查看>>
jquery.color.js
查看>>
huffman编码压缩和解压
查看>>
ssm基础配置
查看>>
jquery 自动运行JS 和如何点击标签运行js 及淡入,淡出效果时 如何附加JS函数
查看>>
mysql备份数据库出错mysqldump: [ERROR] unknown option '--no-beep'
查看>>