zoukankan      html  css  js  c++  java
  • HDU 6075 Questionnaire 17多校4 水题

    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(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 integer T(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 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,计算序列中奇偶个数并比较即可
     
     1 #include <iostream>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #include<queue>
     5 #include<map>
     6 #include<vector>
     7 #include<cmath>
     8 #include<cstring>
     9 using namespace std;
    10 
    11 int main()
    12 {
    13     int T,n,num;
    14     int a,b;
    15     scanf("%d",&T);
    16     while(T--)
    17     {
    18         scanf("%d",&n);
    19         a=0;b=0;
    20         while(n--)
    21         {
    22             scanf("%d",&num);
    23             if(num%2==0)
    24                 a++;
    25             else
    26                 b++;
    27         }
    28         if(a>=b)
    29             printf("%d %d
    ",2,0);
    30         else
    31             printf("%d %d
    ",2,1);
    32     }
    33     return 0;
    34 }
  • 相关阅读:
    CCF NOI1006 捡石头
    POJ NOI MATH-7648 蓄水池水管问题
    CCF NOI1005 存款收益
    CCF NOI1004 填充矩形
    CCF NOI1003 猜数游戏
    CCF NOI1002 三角形
    Project Euler Problem 26 Reciprocal cycles
    HDU1799 循环多少次?
    CCF NOI1001 温度转换
    POJ NOI MATH-7647 余数相同问题
  • 原文地址:https://www.cnblogs.com/Annetree/p/7289269.html
Copyright © 2011-2022 走看看