8 条题解

  • 3
    @ 2026-10-4 9:22:13
    #include <bits/stdc++.h>
    #define LL long long
    using namespace std;
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    int n , m;
    int cnt , sum;
    signed main()
    {
    	   cin >> n >> m;
    	   int ans = (n & m);
    	   while (ans)
    	   {
    		   cnt++;
    		   if(ans & 1)
    		   {
    			   cout << cnt << " ";
    			   sum++;
    		   }
    		   ans >>= 1;
    	   }
    	   if(sum == 0)
    		   cout << 0;
    	   cout << "\n";
    	   if(sum >= 2)
    		   cout << "Yes" << endl;
    	   else
    		   cout << "NO" << endl;
           return 0;
    }
    
    
    • 3
      @ 2025-2-5 16:41:17

      哈利波特是盗墓贼吗

      • 1
        @ 2026-2-11 14:44:57

        #include<bits/stdc++.h> using namespace std; #define int long long int p,q; int cnt,sum; signed main(){ cin>>p>>q; int ans=(p&q); while(ans!=0){ cnt++; if(ans%2){ cout<<cnt<<" "; sum++; } ans/=2; } if(sum==0){ cout<<0<<endl; } cout<<endl; if(sum>=2){ cout<<"Yes"<<endl; } else{ cout<<"NO"<<endl; } return 0; }

        小鸟

        • 1
          @ 2025-11-6 21:41:22

          包AC

          #include<bits/stdc++.h>
          using namespace std;
          int a,b,ans,cnt;
          int main(){
          	cin >> a >> b;
          	ans=a&b;
          	for(int i=1; i<=6; i++){
          		if(ans&1)cnt++,cout << i << " ";
          		ans>>=1;
          	}
          	if(cnt==0) cout << "0\nNO";
          	else if(cnt==1) cout << "\nNO";
          	else cout << "\nYes";
          	return 0;
          }
          
          • 0
            @ 2023-4-29 11:01:35
            #include<bits/stdc++.h>
            using namespace std;
            #define int long long
            int p,q;
            int cnt,sum;
            signed main(){
            	cin>>p>>q;
            	int ans=(p&q);
            	while(ans!=0){
            		cnt++;
            		if(ans%2){
            			cout<<cnt<<" ";
            			sum++;
            		}
            		ans/=2;
            	}
            	if(sum==0){
            		cout<<0<<endl;
            	}
            	cout<<endl;
            	if(sum>=2){
            		cout<<"Yes"<<endl;
            	}
            	else{
            		cout<<"NO"<<endl;
            	}
                return 0;
            }
            
            
            • -2
              @ 2022-7-31 9:57:20

              #include<bits/stdc++.h>

              using namespace std;

              int p, q, a[10000], b[10000], c[10000];

              int main(){

              cin >> p >> q;
              
              int t = 1, t1 = 1;
              
              for(int i = 1; i <= 6; i++){
              
              	a[t] = p % 2;
              
              	b[t1] = q % 2;
              
              	p /= 2;
              
              	q /= 2;
              
              	t++;
              
              	t1++;
              
              }
              
              for(int i = 6; i >= 1; i--){
              
              	if(a[i] == 1){
              
              		if(b[i] == 1){
              
              			c[i] = 1;
              
              		}else{
              
              			c[i] = 0;
              
              		}
              
              	}else{
              
              	    c[i] = 0;
              
                  }
              
              }
              
              int sum = 0;
              
              int sum_1 = 0;
              
              for(int i = 1; i <= 6; i++){
              
              	if(c[i] == 0){
              
              		sum++;
              
              	}else{
              
              		cout << i << " ";
              
              		sum_1++;
              
              	}
              
              }
              
              if(sum == 6){
              
              	cout << "0" << endl;
              
              	
              }else{
              
              	cout<< endl;
              
              	
              }
              
              if(sum_1 < 2){
              
              	cout << "NO";
              
              }else{
              
              	cout << "Yes";
              
              }
              
              return 0;
              

              }

              • -3
                @ 2023-5-30 17:16:17
                using namespace std;
                int n,m,cnt;
                int main(){
                	cin >> n >> m;
                	int ans = n & m;
                	for (int i=1; i<=8; i++){
                		if((ans&1)==1){
                			cout << i <<" ";
                			cnt ++;
                		}
                		ans >>=1;
                	}
                	if(cnt == 0)cout << "0\nNO";
                	else if(cnt == 1)cout << "\nNO";
                	else cout << "\nYes";
                	
                	
                	return 0;
                }
                
                
                • -6
                  @ 2024-12-10 16:57:53
                  #include<bits/stdc++.h>
                  using namespace std;
                  #define int long long
                  int p,q;
                  int cnt,sum;
                  signed main(){
                  	cin>>p>>q;
                  	int ans=(p&q);
                  	while(ans!=0){
                  		cnt++;
                  		if(ans%2){
                  			cout<<cnt<<" ";
                  			sum++;
                  		}
                  		ans/=2;
                  	}
                  	if(sum==0){
                  		cout<<0<<endl;
                  	}
                  	cout<<endl;
                  	if(sum>=2){
                  		cout<<"Yes"<<endl;
                  	}
                  	else{
                  		cout<<"NO"<<endl;
                  	}
                      return 0;
                  }
                  
                  小鸟
                  
                  • 1

                  信息

                  ID
                  2554
                  时间
                  1000ms
                  内存
                  256MiB
                  难度
                  7
                  标签
                  递交数
                  1069
                  已通过
                  244
                  上传者