CF364D.Ghd
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
John Doe offered his sister Jane Doe find the gcd of some set of numbers a.
Gcd is a positive integer g, such that all number from the set are evenly divisible by g and there isn't such g' (g' > g), that all numbers of the set are evenly divisible by g'.
Unfortunately Jane couldn't cope with the task and John offered her to find the ghd of the same subset of numbers.
Ghd is a positive integer g, such that at least half of numbers from the set are evenly divisible by g and there isn't such g' (g' > g) that at least half of the numbers from the set are evenly divisible by g'.
Jane coped with the task for two hours. Please try it, too.
约翰·多伊(John Doe)让他的妹妹简·多伊(Jane Doe)计算某组数 a 的最大公约数(gcd)。
最大公约数(gcd)是一个正整数 g,满足:集合中所有数均可被 g 整除,且不存在另一个正整数 g′(满足 g′>g),使得集合中所有数均可被 g′ 整除。
不幸的是,简未能完成该任务。于是约翰让她改为计算同一数集的“半数最大公约数”(ghd)。
半数最大公约数(ghd)是一个正整数 g,满足:集合中至少一半的数可被 g 整除,且不存在另一个正整数 g′(满足 g′>g),使得集合中至少一半的数可被 g′ 整除。
简花了两个小时完成了该任务。请你也来尝试一下吧。
输入格式
The first line contains an integer n (1 ≤ n ≤ 106) showing how many numbers are in set a. The second line contains space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 1012). Please note, that given set can contain equal numbers.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the %I64d specifier.
第一行包含一个整数 n(1≤n≤106),表示集合 a 中数字的个数。第二行包含 n 个以空格分隔的整数 a1,a2,…,an(1≤ai≤1012)。请注意,给定集合中可能包含相等的数字。
在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符,推荐使用 %I64d 说明符。
输出格式
Print a single integer g — the Ghd of set a.
输出一个整数 g —— 集合 a 的广义最大公约数(Ghd)。
输入输出样例
输入#1
6 6 2 3 4 5 6
输出#1
3
输入#2
5 5 5 6 10 15
输出#2
5
输入解题思路,AI测评打分。不知道怎么写?