一个表,给起始时间和一个数d,每次转动当前的指针指向点数的d倍
直接模拟一下就好,第一遍读错题了 2Y
#include<bits/stdc++.h>
using namespace std;
int n,d;
void Gao()
{
bool f[60]={0};
int tem=n,ans=0;
while (true)
{
tem=(tem+tem*d)%60;
ans++;
if (f[tem])
{
cout<<"Impossible"<<endl;
return;
}
else
{
f[tem]=true;
if (tem==0)
{
cout<<ans<<endl;
return ;
}
}
}
}
int main()
{
// freopen("a.in","r",stdin);
while (cin>>n>>d&& (n||d))
Gao();
return 0;
}