// 2019 3 16.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;
typedef struct bign{
int s[1010];
int len;
bign(){
fill(s,s+1010,0);
len = 0;
}
};
bign convert(char str[]){
bign a;
int len = strlen(str);
a.len = len;
for(int i = 0;i<len;i++){
a.s[i] = str[i]-'0';
}
return a;
}
bign dashuchufa(bign a,int b,int &r){
bign c;
c.len = a.len;
for(int i = 0;i<a.len;i++){
r = r*10+a.s[i];
if(r<b){
c.s[i] = 0;
}else{
c.s[i] = r/b;
r = r%b;
}
}
return c;
}
int _tmain(int argc, _TCHAR* argv[])
{
char str[1010]; int b;
scanf("%s%d",str,&b);
bign a = convert(str);
int r = 0;
bign c = dashuchufa(a,b,r);
int i,j;
for(i = 0;i<c.len;i++){
j = 0;
while(c.s[j] == 0 && j<c.len){
j++;
}
if(j == c.len){
printf("0 %d\n",r);
//system("pause");
return 0;
}
}
for(i = j;i<c.len;i++){
printf("%d",c.s[i]);
}
printf(" %d\n",r);
//system("pause");
return 0;
}