UVA 10494 (暑假-高精度 -D - If We Were a Child Again)

来源:互联网 发布:手机效率软件 编辑:程序博客网 时间:2024/05/16 23:50
#include <cstdio>#include <cstring>int main() {char str_1[10001] = {0}, op;long long num;while (scanf("%s %c %lld", str_1, &op, &num) != EOF) {long long a = 0;char str_2[10001] = {0};int len = strlen(str_1), count = 0;for (int i = 0; i < len; i++) {a = a * 10 + str_1[i] - '0';str_2[count++] = a / num;a %= num;}if (op == '%')printf("%lld", a);else {int k = -1;while (str_2[++k] == 0 && count != 1);while (k < count) {printf("%d", str_2[k++]);}}printf("\n");}return 0;}


0 0