现在的位置: 首页 > 综合 > 正文

UVA550

2013年09月14日 ⁄ 综合 ⁄ 共 202字 ⁄ 字号 评论关闭
#include<stdio.h>

int main(){
	int base, n, m, cnt, end, i;
	while (scanf("%d%d%d", &base, &n, &m) != EOF){
		cnt = 1, i = n * m;
		while (1){
			cnt ++;		
			i = i % base * m + i / base;	
			if (i == n)	
				break;
		}	
		if((m == 1) || (n == 0))	
			cnt = 1;
		printf("%d\n", cnt);
	}
	return 0;
}

抱歉!评论已关闭.