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. PHP检测用户名是否存在

    reg.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  2. 【你吐吧c#每日学习】10.30 C#Nullable Types

    分两种类型,value type and reference type. By default, value type owns a default value. For integer, the d ...

  3. Aptana Studio3开发Python和Ruby(最佳工具)

    即从: http://d1iwq2e2xrohf.cloudfront.net/tools/studio/standalone/3.3.1.201212171919/win/Aptana_Studio ...

  4. android ANR问题

    一.什么是ANR ANR:Application Not Responding: 具体请参考:http://blog.csdn.net/dadoneo/article/details/8270107

  5. Java用native2ascii命令做unicode编码转换

    背景:在做Java开发的时候,常常会出现一些乱码,或者无法正确识别或读取的文件,比如常见的validator验证用的消息资源(properties)文件就需要进行Unicode重新编码.原因是java ...

  6. 常见http代码错误原因及处理

    常见的HTTP错误可以分为以下四大类.每一大类又细分为很多类小错误.当您打不开网站或者打开网站报错时首先检查您输入的网站是否有误,检查网络是否有问题或者虚拟主机的DNS是否可以解析.确定没有问题时再看 ...

  7. bash广播

    terminal1$: mkfifo script_name terminal2$: cat script_name terminal1$: script -f script_name 可以发广播到t ...

  8. [div+css]竖排菜单

             }          #box{              width:120px;              font-size: 12px;              font- ...

  9. Asp.net的post提交方式

    //建立WebRequest对象,url目标地址HttpWebRequest req =(HttpWebRequest)WebRequest.Create(url); //将LoginInfo转换为b ...

  10. linux驱动的入口函数module_init的加载和释放【转】

    本文转载自:http://blog.csdn.net/zhandoushi1982/article/details/4927579 就像你写C程序需要包含C库的头文件那样,Linux内核编程也需要包含 ...