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的更多相关文章
随机推荐
- for...of 与 for...in 区别
一.for...of 1.定义 for...of 语句遍历可迭代对象(包括数组.Set 和 Map 结构.arguments 对象.DOM NodeList 对象.字符串等). 2.语法 for (v ...
- a标签的href和onclick
1.链接的onclick事件被先执行,href的事件后执行 2.就今天遇到的问题说一下,通过a标签的onclick事件实现点击后定位到指定的div,或者是执行其他函数(比如弹出artdialog等), ...
- [ngClass]、[ngStyle]的基本使用(转载)
1.ngStyle 基本用法 <div [ngStyle]="{'background-color':'green'}"></<div> 判断添加 & ...
- Linux的进程/线程通信方式总结(转)
Linux系统中的进程通信方式主要以下几种: 同一主机上的进程通信方式 * UNIX进程间通信方式: 包括管道(PIPE), 有名管道(FIFO), 和信号(Signal) * System V进程通 ...
- IO阻塞模型 非阻塞模型
IO阻塞模型(blocking IO) 在linux中,默认情况下所有的socket都是blocking,一个典型的读操作流程大概是这样: 所以,blocking IO的特点就是在IO执行的两 ...
- UVALive 6915 J - Leveling Ground
思路: 简单模拟下.从左向右扫描一次,求出挖出该区间空地的花费,并取个最小值即可. 至于怎么求区间内的高度最小值,就用线段树就好了. #include <bits/stdc++.h> #d ...
- SQL TOP分页法
原理: PageSize, PageIndex: 升序 order by a asc a的 值 大于, 上一页数据 最大的 a值. 降序 order by a desc a的 值 小于, ...
- 20145217《信网络对抗》逆向与BOF基础实践
20145217<信网络对抗>逆向与BOF基础实践 内容: 一.简单机器指令,汇编语言 1.'objdump -d xxx|more'反汇编命令查看机器代码,'cat'显示文件内容,'xx ...
- Spring_通过注解配置 Bean(1)
beans-annotation.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns ...
- 牛的障碍Cow Steeplechase
题目描述 Farmer John has a brilliant idea for the next great spectator sport: Cow Steeplechase! As every ...