3 条题解
-
4梁晨熙 (rexliang) LV 9 @ 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; }
-
02023-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; }
-
02022-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;
}
- 1
信息
- ID
- 2554
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 759
- 已通过
- 157
- 上传者