3 solutions
-
4
#include<bits/stdc++.h> using namespace std; const int N=20; int a[N]; int main() { int n; cin>>n; for(int i=0;i<1<<n;i++) { for(int j=n-1;j>=0;j--) //从高位枚举到低位 { if(i>>j&1) //i的二进制的第j位存在,说明选了第j个数 { cout<<"Y"; } else //说明第j个没有选 { cout<<"N"; } } cout<<endl; } return 0; }
- 1
Information
- ID
- 949
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 79
- Accepted
- 25
- Uploaded By