题目大意:给出三个数 a,b,c,a 是进制,b 是第一个乘数的最后一位,c 是第二个乘数。求 c 要乘以多少位数后,积的第一位是 b (a 进制下)。
解题思路:百度…强行理解,还是找规律
数学什么的真头疼= =
#include<iostream>
#include<cstdio>
#include<string.h>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main() {
int a, b, c;
while (scanf("%d%d%d", &a, &b, &c) != EOF) {
int tot = 1;
int res = b, tmp = 0, ans = b * c;
while (ans != b) {
tot++;
res = ans % a;
tmp = ans / a;
ans = res * c + tmp;
}
printf("%d\n", tot);
}
return 0;
}