/*
UVA11827 Maximum GCD
https://vjudge.net/contest/153365#problem/V
数论 gcd
水题,然而读入比较坑
*
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
//#define test
using namespace std;
const int Nmax=; long long gcd(long long a,long long b)
{
if(b==0LL)
return a;
return gcd(b,a%b);
}
long long num[Nmax]; int read(long long &a)
{
long long ans=0LL;
char c=getchar();
while(c==' ')
c=getchar();
int flag=;
while(c>='' && c<='')
{
flag=;
ans=ans*10LL+c-'';
c=getchar();
}
if(flag)
{
a=1LL;
return ;
}
a=ans;
if(c=='\n')
{
//a=1LL;
return ;
}
return ;
} int main()
{
#ifdef test
freopen("uva.in","r",stdin);
#endif
int n;
scanf("%d",&n);
getchar();
while(n--)
{
long long mmax=-1LL;
int m=;
while(read(num[++m]));
//for(int i=1;i<=m;i++)
//printf("%d ",num[i]);
//printf("\n");
for(int i=;i<=m;i++)
{
for(int j=i+;j<=m;j++)
{
mmax=max(mmax,gcd(num[i],num[j]));
}
}
printf("%lld\n",mmax);
}
return ;
}

UVA11827 Maximum GCD的更多相关文章

  1. UVA 11827 Maximum GCD

    F - Maximum GCD Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Given the ...

  2. Maximum GCD(fgets读入)

    Maximum GCD https://vjudge.net/contest/288520#problem/V Given the N integers, you have to find the m ...

  3. Maximum GCD (stringstream)题解

    Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possiblepa ...

  4. 邝斌带你飞之数论专题--Maximum GCD UVA - 11827

    Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible p ...

  5. UVA - 11827 - Maximum GCD,10200 - Prime Time (数学)

    两个暴力题.. 题目传送:11827 Maximum GCD AC代码: #include <map> #include <set> #include <cmath> ...

  6. Maximum GCD(UVA 11827)

    Problem:Given the N integers, you have to find the maximum GCD (greatest common divisor) of every po ...

  7. Codeforces Round #651 (Div. 2) A Maximum GCD、B GCD Compression、C Number Game、D Odd-Even Subsequence

    A. Maximum GCD 题意: t组输入,然后输入一个n,让你在区间[1,n]之间找出来两个不相等的数a,b.求出来gcd(a,b)(也就是a,b最大公约数).让你求出来最大的gcd(a,b)是 ...

  8. UVA 11827 Maximum GCD (输入流)

    题目:传送门 题意:求n个数的最大公约数,暴力不会超时,难点在没有个数控制的输入. 题解:用特殊方法输入. #include <iostream> #include <cmath&g ...

  9. UVA 11827 Maximum GCD【GCD,stringstream】

    这题没什么好说的,但是输入较特别,为此还WA了一次... 题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...

随机推荐

  1. POJ 3080 Blue Jeans (后缀数组)

    题目大意: 求出这些DNA序列中的最长且字典序最小的公共子串. 思路分析: 二分长度的答案,去height中扫描这个长度是否满足,一旦满足就立即输出.这样就能够保证字典序最小了. #include & ...

  2. 【cl】基本数据类型

    8种基本数据类型 整数的演示:任何数据在内存中都是2进制的数据 内存中没有10进制没有16进制 byte 范围: -128 ~127 short 范围:-32768 ~ 32768 int 范围:-2 ...

  3. Vue环境搭建+VSCode+Win10

    一.安装Node.js(js的运行环境) 1.在Node.js官网https://nodejs.org/en/download/下载安装包.2.下载后进行安装.3.打开命令行,输入node -v可以查 ...

  4. Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)

    今天配置Spring的xml出现了错误 Multiple annotations found at this line: - schema_reference.4: Failed to read sc ...

  5. EOJ 1114 素数环

    题意 一个由自然数 1…n (n≤18) 素数环就是如下图所示,环上任意两个节点上数值之和为素数. 1 / \   4  2 \ /    3 Input 输入只有一个数 n,表示你需要建立一个 1… ...

  6. 网络:万维网(WWW)

    ylbtech-网络:万维网(WWW) www (万维网缩写)同义词 万维网一般指www(万维网缩写)WWW是环球信息网的缩写,(亦作“Web”.“WWW”.“'W3'”,英文全称为“World Wi ...

  7. UVA-12578 10:6:2 计算几何 模拟

    题面 题意:给你一块长方形,告诉你长:宽=10:6 里面有一个圆,长:半径=5:1,给你长方形的长,求圆的面积和剩余部分的面积 题解:直接模拟输出就好 #include<bits/stdc++. ...

  8. 组合模式(composite)C++实现

    组合模式 意图: 将对象组合成树形结构以表示‘部分-整体’的层次结构,所以有时候又叫做部分-整体模式.组合模式使得用户对单个对象和组合对象的使用具有一致性.,它使我们树型结构的问题中,模糊了简单元素和 ...

  9. DB2大数据量优化查询解决方案

    利用DB2表分区的功能对大数据量的表进行分区,可以优化查询. 表分区介绍: 表分区是一种数据组织方案,它根据一列或多列中的值把表数据划分为多个称为数据分区 的存储对象. (我觉得表分区就类似于Wind ...

  10. css relative设置top为百分比值

    前言: 最近在学习HTML.CSS的过程中,想模仿一下百度首页.发现搜索框这一部分与上下其它元素的空白距离可以随着窗口大小变化(效果如下图所示),于是自己研究了一下并记录下来. 效果实现 <!D ...