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

UVA350

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

int vis[10005];

int main(){
	int Z, I, M, L, t = 0;
	while(scanf("%d%d%d%d", &Z, &I, &M, &L) && Z && I && M && L){
		memset(vis, 0, sizeof(vis));	
		int cnt = 0, k;		
		while (1){	
			L = (Z * L + I) % M;		
			if (vis[L])	
				break;
			cnt++;	
			vis[L] = 1;	
		}		
		printf("Case %d: %d\n", ++t, cnt);
	}
	return 0;
}

抱歉!评论已关闭.