1 32 2
4
#include <iostream>
//#include <cmath> //pow函数在这里用不了,一直无法提交通过
using namespace std;
int main()
{
int n;
long long k,m,l,i,j,jj,t;
cin>>n;
while(n--)
{
cin>>m>>k;
l=1;
while(k--)
l*=10;
j=m%l;
jj=j;
t=-1;
for(i=0;i<l;i++)
{
jj=jj*m%l;
if(jj==j)
{
t=i+1;
break;
}
}
cout<<t<<endl;
}
return 0;
}原文地址:http://blog.csdn.net/u011694809/article/details/46411947