E - Teams

 1 /*
 2 n个学校,第i个有 个参赛者,一个队伍k个人,每个队伍所有人必须来自同一学校,
 3 求k使得队伍数量m最少。
 4 因为k必须整除每个学校的参赛者数量
 5 直接用gcd
 6 */
 7 #include <bits/stdc++.h>
 8 using namespace std;
 9 int gcd(int a,int b)
10 {
11      return b ? gcd(b,a%b) : a;
12 }
13 int main()
14 {
15     int n;
16     scanf("%d",&n);
17     while(n--)
18     {
19         int m;
20         int num[1010];
21         scanf("%d",&m);
22         for(int i=0;i<m;i++)
23             scanf("%d",&num[i]);
24         if(m==1)
25         {
26             printf("%d 1\n",num[0]);
27             continue;
28         }
29         int b=gcd(num[0],num[1]);
30         for(int i=2;i<m;i++)
31             b=gcd(b,num[i]);
32         int sum=0;
33         for(int i=0;i<m;i++)
34             sum=sum+num[i]/b;
35         printf("%d %d\n",b,sum);
36     }
37 }
时间: 2024-10-25 05:44:26

E - Teams的相关文章

Teams(uva11609+组合)

I - Teams Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 11609 题意:有n个人,选多个人参加比赛,其中一个是队长,队长不同其他选手相同也算作不同的方案,.问你一共有多少种方案. 思路:自己才纸上稍微推理一下,n*2n-1%mod: 转载请注明出处:寻找&星空の孩子 题目链接:UVA 11609 也欢迎来我开的专题刷题.哈哈htt

&quot;is not on any development teams &quot; Xcode的账号错误问题

"***@*** is not on any development teams " Xcode现在在"Accounts"中时不时会出现这个提示. 但其他按钮都是灰色的, 也没有"确定" "刷新"按钮, 实在无奈. 解决方法: 1:进入 "Organizer"页面, 选 "Archives", 2:随便找一个你的archives包, 3:选择右边的Validate, 这时会验证你的开发者

uva10911 - Forming Quiz Teams(记忆化搜索)

题目:uva10911 - Forming Quiz Teams(记忆化搜索) 题目大意:给出N对点的坐标,然后将这2 * N个点分组,Xi代表第i组的点之间的距离,求sum(Xi)最小值. 解题思路:这里的点最多16个,如果暴力求解的话16!,会超时的.这里的点取和不取可以用0和1表示,这样的话所有的状态可以用二进制数X来表示.dp[X]  = Min (dp[newx] + d[i][j]):记录下状态来减少不必要的重复操作. i .j代表点的下标,这些点必须是X状态下没取过的,newx就是

10317 Fans of Footbal Teams

10317 Fans of Footbal Teams 时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC Description Two famous football teams, named AC Milan(AC米兰) and Inter Milan(国际米兰) will have a match in GuangZhou City, which is exciting. So a lot of fans get tog

CodeForces 432A Choosing Teams(水)

Description The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC r

10317 Fans of Footbal Teams(并查集)

10317 Fans of Footbal Teams 时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC Description Two famous football teams, named AC Milan(AC米兰) and Inter Milan(国际米兰) will have a match in GuangZhou City, which is exciting. So a lot of fans get tog

Codeforces Round #273 (Div. 2) B . Random Teams 贪心

B. Random Teams n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a progra

UVA 11609 Teams 组合数学+快速幂

In a galaxy far far away there is an ancient game played among the planets. The specialty of the gameis that there is no limitation on the number of players in each team, as long as there is a captain inthe team. (The game is totally strategic, so so

Random Teams(Codeforces Round 273)

Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a program th

URAL 1106 Two Teams

S - Two Teams Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1106 Description The group of people consists of N members. Every member has one or more friends in the group. You are to write pro