#define MAX 40
#include <stdio.h>
int main()
{
char ch;
long sum;
long count;
// int i,j;
int array[MAX],position;
//printf("%d",(int)('1'));
ch=getchar();
position=0;
while (ch!= '0')
{
sum=0;
count=1;
position=0;
while (ch != ' ')
{
// printf("%d",((int)ch-30));
array[position++]=((int)ch-48);
ch=getchar();
}
// printf(" ");
position--;
while (position != -1)
{
count*=2;
sum+=array[position--]*(count-1);
}
printf("%ld ",sum);
ch=getchar();
}
return 0;
}
#include <stdio.h>
int main()
{
char ch;
long sum;
long count;
// int i,j;
int array[MAX],position;
//printf("%d",(int)('1'));
ch=getchar();
position=0;
while (ch!= '0')
{
sum=0;
count=1;
position=0;
while (ch != ' ')
{
// printf("%d",((int)ch-30));
array[position++]=((int)ch-48);
ch=getchar();
}
// printf(" ");
position--;
while (position != -1)
{
count*=2;
sum+=array[position--]*(count-1);
}
printf("%ld ",sum);
ch=getchar();
}
return 0;
}