Meaning
There is a strange clock only minutes of the pointer, a start to stop at the S branch, and then now have D-type coins, put into the clock will be d*s step, asked to need a few such coins.
Analysis:
The topic is not difficult, read understand should know is the use of the mark, because it is not difficult, I started without looking at the topic on the brush to write well, submitted WA, look at the topic to find is to ask a few coins can make the pointer back to 0. Then it was a tragedy to use a 1~1000 loop (which is the range of D >_<) so it's a tangled one.
Because the journey is the same, so when a certain point is repeated after the impossible to come out.
#include <stdio.h>
#include <string.h>
int main ()
{
int s,d,i,sum;// This is limited to the scope of d rather than the scope of NUM, the title of the second interpretation of the wrong, not because the topic is simple and not carefully read the question.
int flag[60];//The correct procedure is to mark each seat if it appears a second time, then repeat it, it is impossible to achieve 0 while
(scanf ("%d%d", &s,&d)!=eof)
{
sum= s;
i=0;
if (s==0&&d==0) break;
memset (flag,0,sizeof (flag));
while (1)
{
s= (s+s*d)%60;
i++;
flag[s]++;
if (s==0) break;
if (flag[s]==2) break;
if (s==0) printf ("%d\n", I);
else printf ("impossible\n");
}
return 0;
}