10494

#include <iostream>
#include <cstdio>
#include <cstring>
//#include <fstream>

#define ul unsigned long long

using namespace std;

int quotient[10005];
ul remainder;

int main()
{
	char num[10005];
	char op[2];
	int div;
	int pos;
	int j,k;
	//ofstream out;
	//out.open("out_10494.txt");
	while(scanf("%s%s%d",num,op,&div)!=EOF)
	{
		k=0;
		remainder=0;
		for(int i=0;i<strlen(num);i++)
		{
			quotient[k] = 0;
			remainder = remainder*10+(num[i]-'0');
			quotient[k] = remainder/div;
			remainder = remainder%div;
			k+=1;
		}
		if(op[0]=='/')
		{
			for(pos=0;pos<k && quotient[pos]==0 ;pos++)
				;
			if(pos==k)
				printf("0\n");
				//out<<"0\n";
			else
			{
				while(pos<k)
					printf("%d",quotient[pos]),
					//out<<quotient[pos],
					pos+=1;
				printf("\n");
				//out<<"\n";
			}
		}
		else if(op[0]=='%')
		{
			printf("%llu\n",remainder);
			//out<<remainder<<"\n";
		}
	}
	//out.close();
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *