CF1204B

CF1204B-Mislove Has Lost an Array

题意:

给你n,l,r 表示在区间1-n内至少有l个不相同的数至多有r个不相同的数,而且这些数不是1就是偶数而且每个偶数/2得到的数在之前出现过。

解法:

根据题意找规律。
满足条件下,合乎题意的值确定后,将剩余的未赋值的看作1就是最小值,反之,看作合乎条件的最大值为最大值。

CODE:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long

int n,l,r;

int main() {
    scanf("%d%d%d",&n,&l,&r);
    int ans1 = (1 << l) - 1 + (n - l);
    int ans2 = (1 << r) - 1 + (1 << (r - 1)) * (n - r);
    printf("%d %d \n",ans1,ans2);
    //system("pause"); 
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Repulser/p/11391250.html