#include <iostream> #include <string> #include <cmath> int i=0; int a = 0, b = 0, xc = 0, xz = 0, suma = 0, e = 0, ln = 0, lz = 0,w=0; using namespace std; void sprawdz() { while(suma>1) { if(i%2==0) { if(suma%2==1) { xc=1; } if(suma!=1) { suma=suma/2+xz; xz=0; } }else { if(suma%2==1) { xz=1; } if(suma!=1) { suma=suma/2+xc; xc=0; } } } cout<<xc<<endl; cout<<xz<<endl; if(xc==1&&xz==1) { }else { w=w+1; } } int main(){ cin >> a >> b; string k; cin >> k; for (int i = 0; i < k.size(); i++) { if (k[i] == 'N') { ln++; //k.replace(i, 1, NULL); } else if (k[i] == 'Z') { lz++; } } for(int i=0;i<pow(2,ln);i++) { lz=lz+i; suma = k.size() - lz + (lz * 2); sprawdz(); } cout<<w; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include <iostream> #include <string> #include <cmath> int i=0; int a = 0, b = 0, xc = 0, xz = 0, suma = 0, e = 0, ln = 0, lz = 0,w=0; using namespace std; void sprawdz() { while(suma>1) { if(i%2==0) { if(suma%2==1) { xc=1; } if(suma!=1) { suma=suma/2+xz; xz=0; } }else { if(suma%2==1) { xz=1; } if(suma!=1) { suma=suma/2+xc; xc=0; } } } cout<<xc<<endl; cout<<xz<<endl; if(xc==1&&xz==1) { }else { w=w+1; } } int main(){ cin >> a >> b; string k; cin >> k; for (int i = 0; i < k.size(); i++) { if (k[i] == 'N') { ln++; //k.replace(i, 1, NULL); } else if (k[i] == 'Z') { lz++; } } for(int i=0;i<pow(2,ln);i++) { lz=lz+i; suma = k.size() - lz + (lz * 2); sprawdz(); } cout<<w; return 0; } |