| 记录编号 | 334557 | 评测结果 | AAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 1416.[冲刺NOIP2014]倒水 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.015 s | ||
| 提交时间 | 2016-11-01 09:06:29 | 内存使用 | 0.31 MiB | ||
#include<cstdio>
#include<iostream>
#define file(x) "pwater."#x
using namespace std;
int n,k;
int cnt(int x){
int r=0;
while(x){
++r;
x-=x&-x;
}
return r;
}
int main(){
freopen(file(in),"r",stdin);
freopen(file(out),"w",stdout);
cin>>n>>k;
if(k>n) {
cout<<k-n;
return 0;
}
int ans=0;
while(cnt(n)>k){
ans+=n&-n;
n+=n&-n;
}
cout<<ans;
}