给出三个数,第一个数为几进制情况下,第二个数为最后一个数,第三个数为乘数
求出最少要多少位的数才能够使最后一个数变为前一个数。即数a就是把数b的最后一位移到了最前面
模拟乘法这个过程即可。
#include<cstdio>
int main()
{
//freopen("in.txt","r",stdin);
int a,b,c,i;
while(~scanf("%d%d%d",&a,&b,&c)){
int temp1=b,temp2=0,temp3=0;
for(i=1;;i++){
temp2 = temp1*c + temp3;
if(temp2==b) break;
temp1 = temp2%a;
temp3 = temp2/a;
}
printf("%d\n",i);
}
return 0;
}