Archived
1
0
Fork 0
This repository has been archived on 2022-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_clang/numbers/triple.c
2022-02-14 16:00:31 +03:00

27 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);
}