Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define wrench786 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define ll long long
- #define PI (acos(-1.0))
- #define LIMIT 1000000000
- using namespace std;
- int BinOne(ll int n){
- int ans =0;
- while(n!=0){
- if(n&1) ans++;
- n>>=1;
- }
- return ans;
- }
- int main(){
- wrench786
- #ifndef ONLINE_JUDGE
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
- #endif
- int tc,cases=0;
- cin>>tc;
- while(tc--){
- cout<<"Case "<<++cases<<": ";
- ll int n,i,ans1=0,ans2=0;
- cin>>n;
- ans1 = BinOne(n);
- for(i=n+1;;i++){
- ans2 = BinOne(i);
- if(ans1==ans2){
- cout<<i<<endl;
- break;
- }
- }
- }
- #ifndef ONLINE_JUDGE
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement