/*
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. iOS 加入粘贴板的功能(复制功能)

    1.   UIPasteboard *board = [UIPasteboard generalPasteboard]; board.string = @" 须要粘贴的问题字符串" ...

  2. 安卓离线SDK Windows版 资源包下载地址全集

    1.Tools    https://dl-ssl.google.com/android/repository/platform-tools_r19.0.1-windows.zip https://d ...

  3. soapui icon以及resource的理解

    https://www.soapui.org/getting-started/soapui-interface/main-window.html 以调用博客园的api为例 第一个是域名 第二个是res ...

  4. Date and time types

    https://docs.microsoft.com/en-us/sql/t-sql/data-types/date-and-time-types date (Transact-SQL)datetim ...

  5. DNS通道检测 国内学术界研究情况——研究方法:基于特征或者流量,使用机器学习决策树分类算法居多

    http://xuewen.cnki.net/DownloadArticle.aspx?filename=BMKJ201104017&dbtype=CJFD<浅析基于DNS协议的隐蔽通道 ...

  6. [Java] 总结1.5/1.6/1.7版本的特性

    开发过程中接触到了从jdk1.5---jdk1.7的使用,在不同的阶段,都使用过了jdk的一些新特性,操作起来更加方面啦!特此总结了下,以下是测试代码: JDK1.5新特性: 1.自动装箱与拆箱: I ...

  7. kali 下使用 arpspoof 实现 ARP 欺骗

    ARP 欺骗: 一种中间人攻击,攻击者通过毒化受害者的 ARP 缓存,将网关的 MAC 替换成攻击者的 MAC ,于是攻击者的主机实际上就充当了受害主机的网关, 之后攻击者就可以截获受害者发出和接到的 ...

  8. WinSocket聊天程序实例(多线程)

    #pragma comment(lib,"Ws2_32.lib") #include <stdio.h> #include <Winsock2.h> SOC ...

  9. 使用asp.net 开发的一个东平人才网招聘程序

    本人用asp.net 工作已经一两年时间了,在单位一般是做管理系统类的开发,针对的客户大都是政府机关,所以都是内网系统,虽然有成就感,但是无法再互联网上展示.虽然技术一般,但还是希望自己做一个网站在互 ...

  10. Cupid's Arrow[HDU1756]

    Cupid's Arrow Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...