-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10494-2.cpp
58 lines (54 loc) · 925 Bytes
/
10494-2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
long long div(char a[],long long n,char c[])
{
int i,j,t=0,l,d=0,r=0;
long long rem=0;
l=strlen(a);
for(i=0;i<l;i++)
{
rem=(rem*10)+a[i]-48;
if(rem>=n||r!=0)
{
j=rem/n;
rem=rem%n;
c[d]=j+48;
d++;
r=1;
}
}
if(d==0)
{
c[d]='0';
d++;
}
c[d]='\0';
return rem;
}
main()
{
long long n;
char a[100000],c[100000];
char ch;
while(scanf("%s %c %lld",&a,&ch,&n)!=EOF)
{
if(ch=='%')
{
n=div(a,n,c);
printf("%lld\n",n);
}
else if(ch=='/')
{
div(a,n,c);
printf("%s\n",c);
}
}
return 0;
}