首页 > 代码库 > UVA-550

UVA-550

题意

输入进制数n,第一个乘数的最后一位m,第二个乘数k,乘法的结果为mk,

mk的第一位是m,求此时mk的长度

#include<iostream>#include <stdio.h>#include <memory.h>using namespace std;int main(){		int base, end, m;	while (cin >> base >> end >> m)	{		int total = 0;		int k, dx;		dx = 0;		k = end;		while (1)		{			total++;			end = end * m + dx;			dx = end / base;			if(k == end && dx == 0)			{				break;			}			end = end % base;		}		cout << total << endl;	}	return 0;}

  

UVA-550