#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, j=0; string s, o; cin >> n; cin >> s; for(auto &&e : s) if(e == '1') ++j; // {bin(ord(e)).count('1'): e for e in ascii_lowercase} while(n) { // cerr << j << ' ' << n << endl; switch(j/n) { case 3: o += "p"; j-=3; break; case 4: o += "x"; j-=4; break; case 5: o += "z"; j-=5; break; case 6: o += "w"; j-=6; break; default: cout << "NIE\n"; return 0; } --n; } if(j!=0) {cout << "NIE\n"; return 0;} cout << o << '\n'; 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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, j=0; string s, o; cin >> n; cin >> s; for(auto &&e : s) if(e == '1') ++j; // {bin(ord(e)).count('1'): e for e in ascii_lowercase} while(n) { // cerr << j << ' ' << n << endl; switch(j/n) { case 3: o += "p"; j-=3; break; case 4: o += "x"; j-=4; break; case 5: o += "z"; j-=5; break; case 6: o += "w"; j-=6; break; default: cout << "NIE\n"; return 0; } --n; } if(j!=0) {cout << "NIE\n"; return 0;} cout << o << '\n'; return 0; } |