1 32 2
4
// 123.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using
namespace std;
int a[6]={0,10,100,1000,10000,100000};
int main(int argc,
char* argv[])
{
int t;
cin>>t;
while(t--)
{
int
k,count,flag,i;
long long
n,temp;
cin>>n>>k;
count=0;
flag=1;
n=n%a[k];
temp=n;
for(i=0;i<a[k];i++)
{
n=n*temp%a[k];
++count;
if(n==temp)
{
flag=0;
break;
}
}
if(flag)
count=-1;
printf("%d\n",count);
}
return 0;
}
原文:http://www.cnblogs.com/52Cyan/p/3682580.html