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 integer ai to represent his opinion. When finished, the leader will choose a pair of positive interges m(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 of m and k.

 
Input
The first line of the input contains an integer T(1≤T≤15), denoting the number of test cases.

In each test case, there is an integer n(3≤n≤100000) 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(1≤ai≤109), denoting the number that each person chosen.

 
Output
For each test case, print a single line containing two integers m and k, if there are multiple solutions, print any of them.
 
Sample Input
1
6
23 3 18 8 13 9
 
Sample Output
5
3
 
题意:给出n个数a[i],要求你回答任意一组m,k,使得a[i]%m==k的个数大于等于剩余个数
题解:使m=2,计算序列中奇偶个数并比较即可
 
 #include <iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
using namespace std; int main()
{
int T,n,num;
int a,b;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
a=;b=;
while(n--)
{
scanf("%d",&num);
if(num%==)
a++;
else
b++;
}
if(a>=b)
printf("%d %d\n",,);
else
printf("%d %d\n",,);
}
return ;
}

HDU 6075 Questionnaire 17多校4 水题的更多相关文章

  1. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  4. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

  5. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  6. HDU ACM 1073 Online Judge -&gt;字符串水题

    分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...

  7. hdu 1754 I Hate It(线段树水题)

    >>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<a ...

  8. HDU 2086 A1 = ? (找规律推导公式 + 水题)(Java版)

    Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2086 ——每天在线,欢迎留言谈论. 题目大意: 有如下方程:Ai = (Ai-1 ...

  9. HDU 1029 Ignatius and the Princess IV --- 水题

    HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...

随机推荐

  1. React文档(五)组件和props

    组件可以让你将UI分割成独立的,可复用的模块,然后考虑将每个模块彼此隔离.从概念上理解,组件就像js中的函数.他们接受随意的输入(被称为props)然后返回React元素来描述屏幕上应该出现什么. 函 ...

  2. Oracle DB 使用子查询来解决查询

    • 定义子查询 • 描述子查询可以解决的问题类型 • 列出子查询的类型 • 编写单行和多行子查询   • 子查询:类型.语法和准则 • 单行子查询: – 子查询中的组函数 – 带有子查询的HAVING ...

  3. 【转】js 对象按照键值(不分区大小写)排序,生成签名方法

    客户需求小程序端用js生成签名,我们按照要求一步一步解决,并且将请求方法封装到一个utils.js里: 第一步:对关联数组按照键名做正序排序. 第二步:拼接字符串 第三步:将拼接的字符串加上私钥 第四 ...

  4. hashlib 库

    hashlib 库 hash 是一种算法,用来接收一系列数据,经过计算后得到一个hash值 hash值的三大特征: 1. 如果传入的数据一样,得到的hash值一样 2. 只要采用的hash算法固定,无 ...

  5. Matlab函数

    any() 相当于或操作,只要有1,就返回1 all() 相当于与操作,只要有0,就返回0 C = union(A,B): C为A和B的并集.去掉相同元素. C = intersect(A,B) C为 ...

  6. MySQL5.6数据库8小时内无请求自动断开连接

    问题: 最近的项目中,发现Mysql数据库在8个小时内,没有请求时,会自动断开连接,这是MySQL服务器的问题.The last packet successfully received from t ...

  7. C++类型转换的注意事项

    1.如果两个类型可以相互转换,就说他们是关联的. 2.隐式转换是指,由编译器自行转换,而不需要程序员介入的转换. 3.以下情况,编译器会发生隐式转换: 1)在大多数表达式中,比int类型小的整型值会被 ...

  8. 小程序之setData特殊情况 三种情况的wx:if

    比如data{ “a”:{}, "b":{} } 你想完成这样的结构 //创建一个对象 var readyData={} //对象[key] =另一个对象 readyData[ke ...

  9. 页面显示时间js

    //页面显示时间 <span align="left" id="OperatorTime"> </span> <script> ...

  10. SQL-10 获取所有非manager的员工emp_no

    题目描述 获取所有非manager的员工emp_noCREATE TABLE `dept_manager` (`dept_no` char(4) NOT NULL,`emp_no` int(11) N ...