Description

ACM-SCPC-2017 is approaching every university is trying to do its best in order to be the Champion, there are n universities, the ith of them has exactly ai contestants. No one knows what is the official number of contestants in each team yet, this year organizers are planing to minimize number of teams participating in the contest but they still want every contestant to participate, so they should select a number k so that each team will consist of exactly k contestant from the same university. Every contestant will belong to one team exactly, and number of these teams is as minimum as possible. Your job is to help the organizers in their task by writing a program that calculates two integers k, the number of contestants in each team, and m, the minimum number of teams will participate. 1 ≤ n ≤ 1000, 1 ≤ ai ≤ 106

Input

First line of input contains an integer T denotes number of test cases. Each test case contains two lines: the first line contains one integern denotes number of universities, while the second line contains n space-separated integers the ith of them denotes number of contestants from the ith university.

Output

For each test case, print one line containing two integers: the first one is k, the size of each team, and the second one is m, the minimum number of teams from all universities according to the previous conditions.

Example
input
2
3
5 15 10
4
4 6 8 12
output
5 6
2 15
题意:有n支队,每个队都有ai的队员,现在重新分配人数,每个队人数相同,且只有相同学校的才能组队,要求队伍数量最少
解法:相同学校的才能组队,也就是说每个队的人数必须都能整除ai,那么应该是求ai的gcd,队伍数量就是拿人数除以gcd
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
int n,m;
int t;
cin>>t;
while(t--)
{
int num;
int sum=0;
cin>>n;
cin>>a[1];
num=a[1];
sum+=a[1];
for(int i=2;i<=n;i++)
{
//int num;
cin>>a[i];
sum+=a[i];
num=__gcd(a[i],num);
}
cout<<num<<" "<<sum/num<<endl;
}
return 0;

  

2016 Al-Baath University Training Camp Contest-1 E的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)

    2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...

  3. 2016 Al-Baath University Training Camp Contest-1 B

    Description A group of junior programmers are attending an advanced programming camp, where they lea ...

  4. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  5. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  6. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  7. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  8. 2016 Al-Baath University Training Camp Contest-1 G

    Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...

  9. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

随机推荐

  1. Ubuntu 16.04 LTS Final Beta about JAVA

    我们知道Ubuntu里可能会事先安装了openjdk.但是我习惯于Oracle jdk. ## < 卸载 openjdk > successfully: ### Terminal comm ...

  2. HDU 2993 MAX Average Problem(斜率优化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 Problem Description Consider a simple sequence w ...

  3. Mac配置环境变量(Java,Android,Gradle,Maven,Hosts)

    JAVA_HOME 配置环境变量 # 使用vim打开.bash_profile文件,加入java环境变量 $ vim .bash_profile export JAVA_HOME=$(/usr/lib ...

  4. .scss写法及如何转化为.css

    scss可视化工具:http://koala-app.com/index-zh.html scss讲解地址:http://www.cnblogs.com/adine/archive/2012/12/1 ...

  5. oracle的索引维护

    索引重建 Alter index idx_name rebuild partition index_partition_name [online nologging] 需要对每个分区索引做rebuil ...

  6. System Hold, Fix Manager before resetting counters

    程序pending http://www.askmaclean.com/archives/2011/11 http://blog.itpub.net/35489/viewspace-717132/ 1 ...

  7. 夺命雷公狗---DEDECMS----3快速入门之隐藏

    如果我们在工作的时候遇到上操蛋的老板,本来公司是做医疗器械的,但是老板突然老了句我们不做医疗了,我们该做电影网,那么我们可以先将原本的栏目进行修改成隐藏栏目, 主要是预防变态老板突然来句“电影网更不好 ...

  8. SQL 中逻辑运算符的优先级

    三个逻辑运算符: NOT AND OR 它们的优先级依次降低(跟多数的高级程序设计语言的优先级顺序一致) 如果要提升某部分的优先级,可以使用半角括号实现 (这点也跟多数高级程序设计语言一致)

  9. 《zw版·Halcon-delphi系列原创教程》 水果自动分类脚本(机器学习、人工智能)

    <zw版·Halcon-delphi系列原创教程> 水果自动分类脚本(机器学习.人工智能) 前面介绍了超市,流水线,酸奶的自动分类算法,下面再介绍一个水果的自动分类算法. Halcon强大 ...

  10. zw版【转发·台湾nvp系列Delphi例程】HALCON color_fuses1

    zw版[转发·台湾nvp系列Delphi例程]HALCON color_fuses1 procedure TForm1.Button1Click(Sender: TObject);var w, h : ...