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(0k<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 of m and k.
 

Input
The first line of the input contains an integerT(1T15), denoting the number of test cases.

In each test case, there is an integer n(3n100000) in the first line, denoting the number of people in the ACM/ICPC team.

In the next line, there are n distinct integers a1,a2,...,an(1ai109), denoting the number that each person chosen.
 

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;}



原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 玲珑骰子沾了水怎么办 花的枝干长歪了怎么办 电脑中毒了怎么办开不了机 台湾竹长得太高怎么办 文竹长得太高怎么办 桑叶牡l丹长虫怎么办 日本海棠开完花后枯萎了怎么办 长寿冠海棠烂根怎么办 夏季长寿冠海棠掉叶怎么办 竹节海棠有点烂根怎么办? 丽格海棠烂茎怎么办 长寿花徒长不开花怎么办 长寿花植株长了怎么办 丽格海棠不爱长怎么办 竹节海棠太高了怎么办 绿萝叶子发黄烂根怎么办 发财树叶子发黄烂根怎么办 君子兰烂根叶子发黄怎么办 四季海棠花叶子干了怎么办 海棠花叶子枯萎枝干发黑怎么办 长寿花叶尖焦了怎么办 新买的盆栽蔫了怎么办 熬中药水太多了怎么办 秋根海棠烂根怎么办 大叶海棠烂根怎么办 玻璃海棠长得很高怎么办 玫瑰海棠叶子干焦怎么办 海棠树树干生虫怎么办 天竺葵花骨朵有虫子了怎么办? 被刺梅的刺扎了怎么办 被刺梅的刺划手了怎么办 虎刺花叶子黄了怎么办 地栽月季叶子发黄怎么办 梅花浇水浇多了怎么办 深水井底下花管进水量小怎么办 盆景对节白腊树叶尖干枯怎么办 四季海棠茎软了怎么办 玫瑰海棠烂根了怎么办 格丽海棠花腌了怎么办 养殖场不能雨污分流怎么办 药店买的药贵了怎么办