#include #define BASE 7 unsigned long int BASEto10(unsigned long int a); unsigned long int DECtoBASE(unsigned long int a); int main(void) { unsigned long int s,d; scanf("%ld", &s); scanf("%ld", &d); if (s <= 4266666666) printf("%d\n", BASEto10(s)); else printf("!\n"); if (d <= 4266666666) printf("%d\n", DECtoBASE(d)); else printf("!\n"); return 0; } unsigned long int BASEto10(unsigned long int a) { if (a == 0) return 0; if (a < 4266666666) { int k=1; long int a10=0; while (a) { a10 += k*(a%10); k *= BASE; a /= 10; } return a10; } return 0; } unsigned long int DECtoBASE(unsigned long int a) { if (a == 0) return 0; if (a < 4266666666) return (a % BASE) + 10 * DECtoBASE(a / BASE); return 0; }