The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online

 

 

ID Title Source
4047 Live Love The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4048 Red Black Tree The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4049 Halting Problem The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4050 Pixel Art The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4051 Infinite Parenthesis Sequence The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4052 Chaleur The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4053 Couleur The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4054 Traveling on the Axis The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4055 Kuririn MIRACLE The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4056 Press the Button The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4057 XOR Clique The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online

 

Live Love


Time Limit: 1 Second      Memory Limit: 65536 KB


DreamGrid is playing the music game Live Love. He has just finished a song consisting of  notes and got a result sequence  ( {PERFECT, NON-PERFECT}). The score of the song is equal to the \textit{max-combo} of the result sequence, which is defined as the maximum number of continuous PERFECTs in the sequence.

Formally speaking,  { |  is an integer and there exists an integer  () such that  PERFECT}. For completeness, we define max() = 0.

As DreamGrid is forgetful, he forgets the result sequence immediately after finishing the song. All he knows is the sequence length  and the total number of PERFECTs in the sequence, indicated by . Any possible score  he may get must satisfy that there exists a sequence  of length  containing exactly  PERFECTs and  NON-PERFECTs and . Now he needs your help to find the maximum and minimum  among all possible scores.

Input

There are multiple test cases. The first line of the input contains an integer (), indicating the number of test cases. For each test case:

The only line contains two integers  and  (, , ), indicating the sequence length and the number of PERFECTs DreamGrid gets.

Output

For each test case output one line containing two integers  and , indicating the maximum and minimum possible score.

Sample Input

5
5 4
100 50
252 52
3 0
10 10

Sample Output

4 2
50 1
52 1
0 0
10 10

Hint

Let's indicate a PERFECT as  and a NON-PERFECT as .

For the first sample test case, the sequence  leads to the maximum score and the sequence  leads to the minimum score.

思维

#include
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        int maxx=m,minn;
        if(n==m)minn=maxx;
        else if(m==0)minn=0;
        else if(m-1<=n-m)minn=1;
        else minn=n/(n-m+1);
        printf("%d %d\n",maxx,minn);
    }
    return 0;
}

 

 

 

XOR Clique


Time Limit: 1 Second      Memory Limit: 65536 KB


BaoBao has a sequence . He would like to find a subset  of  such that ,  and  is maximum, where  means bitwise exclusive or.

Input

There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer  (), indicating the length of the sequence.

The second line contains n integers:  (), indicating the sequence.

It is guaranteed that the sum of  in all cases does not exceed .

Output

For each test case, output an integer denoting the maximum size of .

Sample Input

3
3
1 2 3
3
1 1 1
5
1 2323 534 534 5

Sample Output

2
3
2
/*

题目大意:给定一个数组,在数组中找出最大的子序列,
子序列需要满足的条件是任意两个元素进行异或运算的结果小于两个数中的最小数

解题思路:多找几组数据就会发现若想异或结果小于最小值,只需要两个数二进制形式位数相同,
即二进制前面第一位都为1,进行异或运算后就会第一位变为0,自然比原来两个数都小
所以只需要将序列中所有数的二进制形式位数进行统计即可

看位数即可,把每一个数字都化为二进制,然后把位数相同的就加1,因为只有位数相同,并且两个数字的最高位都1的时候,以后之后的数字才有可能比这两个数字都小,所以只要判断位数相同的有多少个就可以了,这样算出来的数据就是要找的最大值。

*/
#include
#include
#include
#include
using namespace std;
int main()
{
    int t, n, x;
    scanf("%d", &t);
    while(t--)
    {
        int a[30] = {0};
        scanf("%d", &n);
        while(n--)
        {
            scanf("%d", &x);
            int y = 0;//用来记录该数转换为二进制后有多少位
            while(x > 1)
            {
                y++;
                x /= 2;
            }
            a[y]++;
        }
        int maxn = *(max_element(a, a+30));
        printf("%d\n", maxn);
    }
    return 0;
}

 

你可能感兴趣的:(比赛)