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. poj 题目分类(2)

    初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj329 ...

  2. SQL中索引的原理

    (一)深入浅出理解索引结构         实际上,您可以把索引理解为一种特殊的目录.微软的SQL   SERVER提供了两种索引:聚集索引(clustered   index,也称聚类索引.簇集索引 ...

  3. extjs实现简单的多文件上传(不借助任何插件),以及包含处理上传大文件的错误的各种处理办法

    在extjs的学习过程中,有遇到过有关多文件上传的问题,但是网上的大多数都是专门的去实现多文件上传而去做的组件之类的,没有特别简单的方式,于是小白便做了下面的内容,只是通过动态的去添加extjs的自带 ...

  4. Spring之我见

    Spring 是什么(1) •Spring 是一个开源框架. •Spring 为简化企业级应用开发而生. 使用 Spring 可以使简单的 JavaBean 实现以前只有 EJB 才能实现的功能. • ...

  5. paper 73 :HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像

    HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像.国内的教程基本语焉不详,找到一篇比较详尽的国外教程翻译出来,希望对大家有帮助.^_^ 原文地址:http://p ...

  6. angular ng-href

    farmApp.config([ '$compileProvider', function( $compileProvider ) { $compileProvider.aHrefSanitizati ...

  7. Junit单元测试-环境配置

    JUnit是Java单元测试框架,已经在Eclipse中默认安装.目前主流的有JUnit3和JUnit4.JUnit3中,测试用例需要继承TestCase类.JUnit4中,测试用例无需继承TestC ...

  8. Oracle游标总结

    1.声明游标 declare teacher_id ); teacher_name ); teacher_title ); teacher_sex ); cursor teacher_cur is ; ...

  9. Windows应用层网络模块扫盲

           说到Windows应用层网络通信不得不提winsock,winsock是工作在TCP/IP层的应用层(TCP/IP层分为主机到网络层[比特].网络互联层[数据帧].传输层[数据包].应用 ...

  10. sql2005镜像实现

    -- ===========================================    -- 无论是主体服务器.镜像服务器, 还是见证服务器    -- 除特别说明外,均需要保证下面的操作 ...