2010年9月17日 星期五

ACM 10494 - If We Were a Child Again

#include <stdio.h>

int main()
{
int i, b = 10, first;
char ch[2], m[10000], c;
long long int tmp, j, n;

while (scanf("%s %s %lld", m, ch, &n) == 3)
{
first = 1;
if (ch[0] == '/')
{
tmp = 0;
for (i = 0; (c = m[i]); i ++)
{
tmp *= b;
tmp += c - '0';
j = tmp / n;
if (j != 0) first = 0;
if (!first) printf("%lld", j);
tmp %= n;
}
if (first) printf("0");
printf("\n");
}
if (ch[0] == '%')
{
for (i = 0, tmp = 0; (c = m[i]); i ++)
{
tmp *= b;
tmp += c - '0';
tmp %= n;
}
printf("%lld\n", tmp);
}
}
return 0;
}


回目錄
回首頁

沒有留言 :

張貼留言

Related Posts Plugin for WordPress, Blogger...