1067: 密室寻宝(find)

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using namespace std;

int main(){
    int p ,q;
    int m,n;
    cin>>p>>q;
    m = p & q;
    int i = 0;
    int k = 0;
    
    while(m > 0)
    {
        i++; 
        if(m % 2 > 0)
        {
            if(k == 0)
                cout<<i; 
            else
                cout<<' '<<i; 
            k++;
        }
        m = m /2 ;
    }
    if(k==0)
    {
        cout<<'0'; 
    }
    if(k>=2)
    {
        cout<<endl<<"Open"<<endl;
    }
    else
    {
        
        cout<<endl<<"Close"<<endl;
    }
    
    return 0;
//    cout<<setiosflags(ios::fixed)<<setprecision(4)<<s<<endl;
//    cout<< setiosflags(ios::fixed)<<setprecision(4) <<c<<endl; 
}
原文地址:https://www.cnblogs.com/shiningrise/p/6607712.html