这个题我很无语,一开始看绿题,还是数论,应该不会特别简单,应该要动笔写上好一会,过了一会旁边

#祝神

说这原来是个蓝题,我顿时觉得十分迷茫。。。

结果看了这个题看了一会,仔细一想,woc,这题怕不是可以暴力出解,况且这个范围确实也够了啊,妥妥0ms出解。。就试着打了一下。。然后T两个点。。。过了一会,发现2在进行乘的时候,如果n足够大,会爆出int,所以改成longlong。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define re register
#define wc 0.0000000001
using namespace std;
long long k,n,s,x;
int main()
{
    cin>>n>>k;
    while(k>1)
    {
        k--;
        s=2;
        while(n>=s)
            s<<=1;
        s>>=1;
        n-=s;
        if(n<=1)
        {
            cout<<"0";
            return 0;
        }
    }
    s=2;
    while(n>s)
    s<<=1;
    s-=n;
    cout<<s;
}

 

相关文章:

  • 2022-12-23
  • 2021-05-16
  • 2021-08-28
  • 2021-07-31
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-23
  • 2021-08-26
  • 2021-09-05
  • 2021-06-26
  • 2021-06-15
  • 2021-08-05
相关资源
相似解决方案