Created
October 28, 2012 09:04
-
-
Save sashabaranov/3968104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define BUF_SIZE 256 | |
int main() | |
{ | |
char A[BUF_SIZE], B[BUF_SIZE], C[BUF_SIZE]; | |
scanf("%s %s %s", &A, &B , &C); | |
int base; | |
long int c_A, c_B, c_C; // converted | |
for(base = 2; base < 36; base++) | |
{ | |
c_A = strtol(&A, NULL, base); | |
c_B = strtol(&B, NULL, base); | |
c_C = strtol(&C, NULL, base); | |
if((c_A + c_B) == c_C && (c_A != 0 && c_B != 0 && c_C != 0)) | |
{ | |
printf("%d", base); | |
return 0; | |
} | |
} | |
printf("-1"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment