UVA11827 Maximum GCD
/*
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的更多相关文章
- UVA 11827 Maximum GCD
F - Maximum GCD Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Given the ...
- Maximum GCD(fgets读入)
Maximum GCD https://vjudge.net/contest/288520#problem/V Given the N integers, you have to find the m ...
- Maximum GCD (stringstream)题解
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possiblepa ...
- 邝斌带你飞之数论专题--Maximum GCD UVA - 11827
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible p ...
- UVA - 11827 - Maximum GCD,10200 - Prime Time (数学)
两个暴力题.. 题目传送:11827 Maximum GCD AC代码: #include <map> #include <set> #include <cmath> ...
- Maximum GCD(UVA 11827)
Problem:Given the N integers, you have to find the maximum GCD (greatest common divisor) of every po ...
- 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)是 ...
- UVA 11827 Maximum GCD (输入流)
题目:传送门 题意:求n个数的最大公约数,暴力不会超时,难点在没有个数控制的输入. 题解:用特殊方法输入. #include <iostream> #include <cmath&g ...
- UVA 11827 Maximum GCD【GCD,stringstream】
这题没什么好说的,但是输入较特别,为此还WA了一次... 题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...
随机推荐
- cocos2d-x 是怎样渲染的
要知道 是怎样渲染的:要先选中 就可以 谁知道: c ocos2d-x 是怎样渲染的 ? 每一个CCNODE自己有draw 北京-菜菜: :: draw draw负重渲染 ************** ...
- 《Java程序设计》第16周周五:数据库连接 与 随机数的使用
第一部分:实验项目 项目二:数据库初步. 目的:了解Java连接数据库的步骤与方法.以及MySQL数据库的安装与使用. 目标: (1)在机房安装上MySQL数据库. 安装成功 MySQL数据库 (2) ...
- Linux - 进程与内存查看
top NI表示进程的优先级. -20的优先级,非常的高. top -p xxx 可以查看具体的进程情况. renice -n -6 进程ID 可以改变一个正在运行的pid的优先级. [root@lo ...
- c# xml操作总结
一前言 先来了解下操作XML所涉及到的几个类及之间的关系 如果大家发现少写了一些常用的方法,麻烦在评论中指出,我一定会补上的!谢谢大家 * 1 XMLElement 主要是针对节点的一些属性进行操作 ...
- Arduino-1602-LiquidCrystal库
前言:LiquidCrystal是一个1602的IIC库,使用IIC协议可以极大节约用线数量,十分方便.当然,前提是1602要使用LCD1602 I2C模块. 一.库函数快速查询 LiquidCrys ...
- JS form 表单收集 数据 formSerialize
做后台系统的时候通常会用到form表单来做数据采集:每次一个字段一个字段的去收集就会很麻烦,网站也有form.js插件可以进行表单收集,并封装成一个对象,通过ajax方法传到后台:现在介绍一种直觉采集 ...
- 使用Custom scrollbar(彩色滚动条)插件实现WordPress滚动条变色的方法
1.在插件中心关键词搜索Custom scrollbar 2.按照说明操作就行 查看演示:sheji.xinlvtian.com
- (转)es6用法
如何在浏览器中使用es6的语法呢? 方法一:引入文件相关js文件 <script src="traceur.js"></script> <script ...
- MySQL 5.6 Reference Manual-14.7 InnoDB Table Compression
14.7 InnoDB Table Compression 14.7.1 Overview of Table Compression 14.7.2 Enabling Compression for a ...
- MySQL结构相关
MySQL 由以下几部分组成: 1.Connectors指的是不同语言中与SQL的交互 2.Management Serveices & Utilities: 系统管理和控制工具 3.Conn ...