#include <iostream>
#include <cstdio>
#include <string.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAXN 1000 + 10
struct Bign
{
int len;
int s[MAXN];
}a, ans;
void output(Bign temp)
{
int u = 0;
while (u < temp.len - 1 && temp.s[u] == 0)
{
u++;
}
for (int i = u; i < temp.len; i++)
{
cout << temp.s[i];
}
cout << endl;
}
void div(Bign temp, long long num)
{
long long t = 0;
for (int i = 0; i < temp.len; i++)
{
t = t * 10 + temp.s[i];
ans.s[i] = t / num;
t = t % num;
}
ans.len = temp.len;
}
int mod(Bign temp, long long num)
{
long long t = 0;
for (int i = 0; i < temp.len; i++)
{
t = t * 10 + temp.s[i];
t = t % num;
}
return t;
}
void input()
{
string str;
char ch;
long long num;
while (cin >> str >> ch >> num)
{
a.len = str.length();
for (int i = 0; i < MAXN; i++)
{
a.s[i] = ans.s[i] = 0;
}
for (int i = 0; i < a.len; i++)
{
a.s[i] = str[i] - '0';
}
if (ch == '/')
{
div(a, num);
output(ans);
}
else
{
cout << mod(a, num) << endl;
}
}
}
int main()
{
input();
return 0;
}
ACM->uva10494
最新推荐文章于 2018-10-29 22:11:47 发布