文章

83

粉丝

2

获赞

592

访问

63.8k

头像
排列与二进制 题解:
P1368 吉林大学机试题
发布于 2026年3月
阅读数 783

#include <iostream>
using namespace std;

int count2(int x){
	int cnt = 0;
	while(x%2==0){
		cnt++;
		x /=2;
	}
	return cnt;
}

int main(){
	int n,m;
	
	while(cin >> n >> m){	
		if(n==0 && m==0)
			break;
		int ans=0;
		
		for(int i=0;i<m;i++){
			ans +=count2(n-i);
		}
		
		cout << ans << endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发