2017 Multi-University Training Contest
来源:互联网 发布:金山软件管家下载 编辑:程序博客网 时间:2024/06/05 06:37
题目:
Questionnaire
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1585 Accepted Submission(s): 914
Special Judge
Problem Description
In order to get better results in official ACM/ICPC contests, the team leader comes up with a questionnaire. He asked everyone in the team whether to have more training.
Picture from Wikimedia Commons
Obviously many people don't want more training, so the clever leader didn't write down their words such as ''Yes'' or ''No''. Instead, he let everyone choose a positive integerai to represent his opinion. When finished, the leader will choose a pair of positive intergesm(m>1) and k(0≤k<m) , and regard those people whose number is exactly k modulo m as ''Yes'', while others as ''No''. If the number of ''Yes'' is not less than ''No'', the leader can have chance to offer more training.
Please help the team leader to find such pair ofm and k .
Picture from Wikimedia Commons
Obviously many people don't want more training, so the clever leader didn't write down their words such as ''Yes'' or ''No''. Instead, he let everyone choose a positive integer
Please help the team leader to find such pair of
Input
The first line of the input contains an integerT(1≤T≤15) , denoting the number of test cases.
In each test case, there is an integern(3≤n≤100000) in the first line, denoting the number of people in the ACM/ICPC team.
In the next line, there aren distinct integers a1,a2,...,an(1≤ai≤109) , denoting the number that each person chosen.
In each test case, there is an integer
In the next line, there are
Output
For each test case, print a single line containing two integersm and k , if there are multiple solutions, print any of them.
Sample Input
1623 3 18 8 13 9
Sample Output
5 3
题意:求出m和k,使得给定数组的过半的元素值%m=k。签到题
CODE:
#include<bits/stdc++.h>using namespace std;int a[100002];int main(){ int t,n,i,j; scanf("%d",&t); while(t--){ scanf("%d",&n); int x=0,y=0; for(i=0;i<n;i++){ scanf("%d",&a[i]); a[i]%2?x++:y++; } printf("2 %d\n",x>y?1:0); } return 0;}
阅读全文
0 0
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- Jdbc封装公共CRUD方法,十分简便
- 超级简单的Android Studio jni 实现(无需命令行)
- 2.2线性表的顺序表示和实现
- FFMPEG之图片系列 --- tif 格式
- PB使用ODBC连接MYsql乱码问题解决!
- 2017 Multi-University Training Contest
- Java邮件开发(二):使用JMail发送一封图文并茂且包含附件的邮件(上)
- HDU 4417 Super Mario(线段树||树状数组+离线操作 之树状数组篇)
- c++中namespace(命名空间)
- 欢迎使用CSDN-markdown编辑器
- Spring Cloud Eureka Server HA With Docker
- poj 2559 & hdu 1506 Largest Rectangle in a Histogram 笛卡尔树
- 请编写一个C函数,该函数将一个字符串逆序
- python 正则表达式元字符详细介绍