hdu1393 Weird Clock

#include <stdio.h>

int main()
{
	int s,d,flag,ans;
	while(scanf("%d %d",&s,&d))
	{
		flag=ans=0;
		if(s+d==0)
			break;
		while(s!=0)
		{
			s=(s+s*d)%60;
			ans++;
			if(ans>1000)
			{
				flag=1;
				break;
			}
		}
		if(s>0||flag==1)
			printf("Impossible\n");
		else
			printf("%d\n",ans);
	}
	return 0;
}

你可能感兴趣的:(hdu1393 Weird Clock)