#include <iostream>
#include <stdio.h>
using namespace std;
char tab[7] = {'-','+','/','a','q','v','w'};
void wypisz(long long &ones, long long &x, long long n, int p)
{
while ((ones-p) >= 3*(n-x-1) && (ones-p) <= p*(n-x-1) && n>x)
{
//printf("(ones:%lld x:%lld n:%lld p:%d)\n",ones,x,n,p);
printf("%c",tab[p]);
x++;
ones-=p;
}
}
int main() {
// your code goes here
long long n,ones=0;
scanf("%lld\n",&n);
//printf("%lld\n",n);
for(long long i=0;i<8*n;i++)
{
char c;
scanf("%c",&c);
//printf("%c",c);
ones+=(c=='1');
}
//printf("ones:%lld\n",ones);
if(ones < n*3 || ones >n*6)
{
printf("NIE");
return 0;
}
long long x=0;
//printf("ones %lld\n", ones);
wypisz(ones, x, n, 6);
wypisz(ones, x, n, 5);
wypisz(ones, x, n, 4);
wypisz(ones, x, n, 3);
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 | #include <iostream> #include <stdio.h> using namespace std; char tab[7] = {'-','+','/','a','q','v','w'}; void wypisz(long long &ones, long long &x, long long n, int p) { while ((ones-p) >= 3*(n-x-1) && (ones-p) <= p*(n-x-1) && n>x) { //printf("(ones:%lld x:%lld n:%lld p:%d)\n",ones,x,n,p); printf("%c",tab[p]); x++; ones-=p; } } int main() { // your code goes here long long n,ones=0; scanf("%lld\n",&n); //printf("%lld\n",n); for(long long i=0;i<8*n;i++) { char c; scanf("%c",&c); //printf("%c",c); ones+=(c=='1'); } //printf("ones:%lld\n",ones); if(ones < n*3 || ones >n*6) { printf("NIE"); return 0; } long long x=0; //printf("ones %lld\n", ones); wypisz(ones, x, n, 6); wypisz(ones, x, n, 5); wypisz(ones, x, n, 4); wypisz(ones, x, n, 3); return 0; } |
English