17暑假多校联赛4.9 HDU 6075 Questionnaire
来源:互联网 发布:bp神经网络的java实现 编辑:程序博客网 时间:2024/06/13 11:27
Questionnaire
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 524288/524288 K (Java/Others)
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 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
1623 3 18 8 13 9
Sample Output
5 3
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6075
分析
题意:找出一对m和k,满足给出的数中对m取模等于k的数不少于对m取模不等于k的数
因为没规定m和k的取值,所以直接对2取模,取模等于1的少的话,就让k为0,反之k为1
代码
#include <iostream>#include <cstdio>using namespace std;int a[100001];int main(){ int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int sum1=0,sum2=0; for(int i=0; i<n; i++) { scanf("%d",&a[i]); if(a[i]%2==1) sum1++; else sum2++; } if(sum1>=sum2) printf("2 1\n"); else printf("2 0\n"); } return 0;}
- 17暑假多校联赛4.9 HDU 6075 Questionnaire
- hdu 多校联赛 Questionnaire
- HDU 2017 多校联赛4 1009 Questionnaire
- hdu-暑假集训-Questionnaire
- 17暑假多校联赛1.2 HDU 6034 Balala Power!
- 17暑假多校联赛2.11 HDU 6055 Regular polygon
- 17暑假多校联赛2.3 HDU 6047 Maximum Sequence
- 17暑假多校联赛1.3 HDU 6035 Colorful Tree
- 17暑假多校联赛1.6 HDU 6038 Function
- 17暑假多校联赛2.6 HDU 6050 Funny Function
- 17暑假多校联赛4.3 HDU 6069 Counting Divisors
- 17暑假多校联赛4.12 HDU 6078 Wavel Sequence
- 17暑假多校联赛6.8 HDU 6103 Kirinriki
- 17暑假多校联赛7.11 HDU 6130 Kolakoski
- 17暑假多校联赛7.5 HDU 6124 Euler theorem
- HDU6075 Questionnaire(思路,2017 HDU多校联赛 第4场)
- 17暑假多校联赛2.1 HDU 6045 Is Derek lying?
- 17暑假多校联赛2.8 HDU 6052 To my boyfriend
- 世界排名前100的古典音乐榜单
- NYOJ 915 +-字符串
- 关于华为手机自定义view中NavigationBar显示与隐藏造成高度问题的解决办法
- 称不上项目的小程序3:计算器
- SpringMVC中的异常处理
- 17暑假多校联赛4.9 HDU 6075 Questionnaire
- wireshark的简单使用
- Docker基础教程(6)进阶命令-3-分享你的镜像
- C++ STL 之 vector
- struts2的API
- [72000][1653] ORA-01653: 表 ***无法通过 128 (在表空间 **中) 扩展 ORA-06512: 在 "****", line 8
- 数字三角形(数塔) DP入门
- 最大连续bit数
- xtrabackup 2.4.6 的源码安装