This file contains 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
/** | |
* Author : Md.Mehadi Hasan Menon. | |
* Problem : 10494 - If We Were a Child Again. | |
* Status : Accepted. | |
* Date : 09.10.2014. | |
**/ | |
#include <stdio.h> | |
char s[10001]; | |
char opt[3]; | |
int main() | |
{ | |
int num[10001], i, len; | |
long long int b, rem; | |
while(scanf("%s %s %d", &s, &opt, &b) != EOF) | |
{ | |
rem = 0; len = 0; | |
for(i = 0; s[i]; i++) | |
{ | |
rem = rem * 10 + s[i] - '0'; | |
num[len++] = rem / b; /* Take div in an array */ | |
rem = rem % b; | |
} | |
if(opt[0] == '/') | |
{ | |
/* Delet zero before decimal number */ | |
for(i = 0; i < len && num[i] == 0; i++) | |
; | |
if(len == i) | |
{ | |
printf("0"); | |
} | |
else | |
{ | |
for( ; i < len; i++) | |
{ | |
printf("%d", num[i]); | |
} | |
} | |
printf("\n"); | |
} | |
else | |
{ | |
printf("%lld\n", rem); | |
} | |
} | |
return 0; | |
} |
Comments
Post a Comment