1 solutions
-
3
符合题目名
#include<bits/stdc++.h> using namespace std; int n; int popc(int x){//统计1的个数(打过csp初赛的都知道) int ans=0; while(x){ x&=(x-1); ans++; } return ans; } int main(){ while(cin>>n&&n!=0){ int tp=popc(n); for(int i=1;;i++){//数据不大直接枚举 int m=n+i; if(popc(m)==tp){ cout<<m<<"\n"; break; } } } return 0; }
- 1
Information
- ID
- 708
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- # Submissions
- 15
- Accepted
- 4
- Uploaded By