nihonium
/
mipt_clang
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

28 lines
371 B
C

#include <stdio.h>
#include <string.h>
int pow_(int x, int y) {
if (!y) {
return 1;
}
int res = x;
for (int i = 1; i <= y-1; ++i) {
res = res*x;
}
return res;
}
int main() {
char nya[10000];
int res = 0;
scanf("%s", nya);
int len = strlen(nya);
for (int i = len-1; i >= 0; --i) {
res += (nya[i] - '0') * pow_(3, len-i-1);
}
printf("%d\n", res);
}