The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online

 

 

IDTitleSource
4047Live LoveThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4048Red Black TreeThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4049Halting ProblemThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4050Pixel ArtThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4051Infinite Parenthesis SequenceThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4052ChaleurThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4053CouleurThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4054Traveling on the AxisThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4055Kuririn MIRACLEThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4056Press the ButtonThe 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
4057XOR CliqueThe 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<bits/stdc++.h>
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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值