uva11827gcd
gcd裸题,不过输入要注意gets会tle,要用快速读入
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; ll a[N];
ll gcd(ll a,ll b)
{
if(a<b)swap(a,b);
return b?gcd(b,a%b):a;
}
int main()
{
/* ios::sync_with_stdio(false);
cin.tie(0);*/
ll n,ans=;
scanf("%d",&n);
while (getchar() != '\n');
while (n --) {
char buf;
int cnt = ;
while ((buf = getchar()) != '\n')
if (buf >= '' && buf <= '') {
ungetc(buf,stdin);
scanf("%d",&a[cnt++]);
}
ll ans=;
for(int i=;i<cnt;i++)
for(int j=i+;j<cnt;j++)
ans=max(ans,gcd(a[i],a[j]));
printf("%lld\n",ans);
}
return ;
}
/*********************
3
10 20 30 40
7 5 12
125 15 25
*********************/
uva11827gcd的更多相关文章
随机推荐
- tpot蜜罐平台搭建
iso安装:https://github.com/dtag-dev-sec/tpotce autoinstaller安装:https://github.com/dtag-dev-sec/tpotce ...
- 7.Insert Methods-官方文档摘录
总结 列举insert插入方法 MongoDB provides the following methods for inserting documents into a collection: db ...
- 如何让socket编程非阻塞?
import socket # 创建socket client = socket.socket() # 将原来阻塞的位置变成非阻塞(报错) client.setblocking(False) # 百度 ...
- 数据库引擎、索引、pymysql
一.数据库存储引擎 1.存储引擎 mysql中建立的库===>文件夹 库中建立的表===>文件 现实生活中我们用来存储数据的文件应该有不同的类型:比如存文本用txt类型,存表格用excel ...
- JAVA三框架工作原理是什么?
一.struts的工作原理: 1.初始化,读取struts-config.xml.web.xml等配置文件(所有配置文件的初始化) 2.发送HTTP请求,客户端发送以.do结尾的请求 3.填充Form ...
- 使用Xcode改动iOS项目project名和路径名
对,好.错.改正. ------ 前言 系统 10.9 开发平台 xcode 5.0 旧project名 MyProject-iPad 改动之后 新project名 FjSk-iPad 点击项目,进入 ...
- php foreach函数的用法
php foreach函数用法举例. Foreach 函数(PHP4/PHP5) foreach 语法结构提供了遍历数组的简单方式. foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类 ...
- Django:学习笔记(3)——REST实现
Django:学习笔记(3)——REST实现 了解REST风格 按照传统的开发方式,我们在实现CURD操作时,会写多个映射路径,比如对一本书的操作,我们会写多个URL,可能如下 web/deleteB ...
- HDU - 6336 Problem E. Matrix from Arrays (规律+二维前缀和)
题意: for (int i = 0; ; ++i) { for (int j = 0; j <= i; ++j) { M[j][i - j] = A[cursor]; cursor = (cu ...
- ASC转换BCD,ASC2BCD(转)
int ASC2BCD(const char* szASC,byte* szBDC) { int szASCLen=strlen(szASC); byte * bpBCD = new by ...