hdu 5207 BestCoder Round #38 ($) Greatest Greatest Common Divisor
#include<stdio.h>
#include<string.h>
#include<math.h>
int flag[];
int a[];
int main()
{
int sb;
scanf("%d", &sb);
int u;
for (u = ; u <= sb; u++)
{
int n, i;
int maxn = -;
scanf("%d", &n);
memset(flag, , sizeof(flag));
for (i = ; i <= n; i++)
{
scanf("%d", &a[i]);
if (a[i] >= maxn) maxn = a[i];
}
for (i = ; i <= n; i++)
{
int j;
for (j = ; j *j <= a[i]; j++)
{
if (a[i] % j == && j*j < a[i]) flag[j]++, flag[a[i] / j]++;
else if (a[i] % j == && j*j == a[i]) flag[j]++;
}
}
int ans;
for (i = maxn; i >= ; i--)
{
if (flag[i] >= ) { ans = i; break; }
}
printf("Case #%d: ", u);
printf("%d\n", ans);
}
return ;
}
hdu 5207 BestCoder Round #38 ($) Greatest Greatest Common Divisor的更多相关文章
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 5643 BestCoder Round #75
King's Game Accepts: 249 Submissions: 671 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6 ...
- hdu 5641 BestCoder Round #75
King's Phone Accepts: 310 Submissions: 2980 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- BestCoder Round #38
1001 Four Inages Strategy 题意:给定空间的四个点,判断这四个点是否能形成正方形 思路:判断空间上4个点是否形成一个正方形方法有很多,这里给出一种方法,在p2,p3,p4中枚举 ...
- HDU 5682/BestCoder Round #83 1003 zxa and leaf 二分+树
zxa and leaf Problem Description zxa have an unrooted tree with n nodes, including (n−1) undirected ...
- HDU 5506 - BestCoder Round #60 - GT and set
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1003 题意 : 给N集 ...
- HDU 5505 - BestCoder Round #60 - GT and numbers
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1002 思路 : N有若 ...
- HDU 5496 - BestCoder Round #58 - Beauty of Sequence
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=637&pid=1002 思路 : 考 ...
- HDU 5568 - BestCoder Round #63 - sequence2
题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=5568 题意 : 给一个长度已知的序列, 给一个值k, 问该序列中有多少种长度为k的上升子序列 思路 ...
随机推荐
- 网络tcp/ip资料
1. Linux TCP/IP 协议栈分析,这是chinaunix.net论坛里的N人写的电子书,可以在这里下载PDF版本.http://blog.chinaunix.net/u2/85263/sho ...
- SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY
SCOPE_IDENTITY.IDENT_CURRENT 和 @@IDENTITY SQL Server 2000中,有三个比较类似的功能:他们分别是:SCOPE_IDENTITY.IDENT_CUR ...
- django安装配置及测试
django安装之前我们假设你已经安装了python,和mysql(不是必须的):(如果没有google一下挺简单不介绍了)下面直接介绍django的安装配置:到下面连接可以下载www.djangop ...
- 用django搭建一个简易blog系统(翻译)(二)
03. Starting the blog app 在这部分,将要为你的project创建一个blog 应用,通过编辑setting.py文件,并把它添加到INSTALLED_APPS. 在你的命令行 ...
- json时间格式的互换
c#代码 public class DateTimeUtil { /// <summary> /// 把json的时间格式还原-服务端 /// </summary> /// & ...
- Java设计模式透析之 —— 适配器(Adapter)
转载请注明出处:http://blog.csdn.net/sinyu890807/article/details/9400141 今天一大早,你的leader就匆匆忙忙跑过来找到你:“快,快,紧急任务 ...
- Use weechat (IRC client) on OS X. MacBook Pro
Weechat is a console IRC client. It is opensource and very easy to use. I use weechat in my Linux PC ...
- MacOSX中使用NSWindow创建背景透明的窗体
1.Windows 在window上创建异形窗体必须要使用WS_EX_LAYERED样式,再调用SetLayeredWindowAttributes设置透明度或者透明颜色属性.用updatelayer ...
- MAC上的包管理利器
Homebrew- MAC上的包管理利器 2013-07-01 16:25 by 黄博文, 76 阅读, 0 评论, 收藏, 编辑 包管理器是神马东西?让我们看看wikipedia上的介绍. In s ...
- SQLsever2008 远程连接错误 linq
如果你也和我一样远程连接一个sqlsever2008数据时出现类似错误 SqlException (0x80131904): 用户 ‘xxxxx' 登录失败. 首先在“服务器资源管理器”中测试一下你的 ...