#include <bits/stdc++.h> using namespace std; #define MIN 3 #define MAX 6 int main() { int n, count = 0; string s; scanf("%d\n", &n); for(int i = 0; i != (n << 3); ++i) { char c = getchar(); count += c - '0'; } if(count > 6 * n || count < 3 * n) { printf("NIE\n"); return 0; } while(n) { --n; if(count - 6 <= 6 * n && count - 6 >= 3 * n) { printf("o"); count -= 6; continue; } else if(count - 3 <= 6 * n && count - 3 >= 3 * n) { printf("a"); count -= 3; continue; } else if(count - 4 <= 6 * n && count - 4 >= 3 * n) { printf("c"); count -= 4; continue; } else if(count - 5 <= 6 * n && count - 5 >= 3 * n) { printf("g"); count -= 5; continue; } } printf("\n"); }
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 | #include <bits/stdc++.h> using namespace std; #define MIN 3 #define MAX 6 int main() { int n, count = 0; string s; scanf("%d\n", &n); for(int i = 0; i != (n << 3); ++i) { char c = getchar(); count += c - '0'; } if(count > 6 * n || count < 3 * n) { printf("NIE\n"); return 0; } while(n) { --n; if(count - 6 <= 6 * n && count - 6 >= 3 * n) { printf("o"); count -= 6; continue; } else if(count - 3 <= 6 * n && count - 3 >= 3 * n) { printf("a"); count -= 3; continue; } else if(count - 4 <= 6 * n && count - 4 >= 3 * n) { printf("c"); count -= 4; continue; } else if(count - 5 <= 6 * n && count - 5 >= 3 * n) { printf("g"); count -= 5; continue; } } printf("\n"); } |