最后两点Wa了
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#define ll unsigned long long
//104858563
using namespace std;
inline ll mult(ll a,ll b,ll p){
ll L=a*(b>>32)%p*(1ll<<32)%p;
ll R=a*(b&((1ll<<32)-1))%p;
return (L+R)%p;
}
template<class T>
inline T qpow(T a,T b,T p){
if(b==0)return 1;
T tmp,base=a;
tmp=1;
while(b!=0){
if(b&1){
tmp*=base;
tmp%=p;
}
base*=base;
base%=p;
b>>=1;
}
return tmp;
}
int main(){
ll k,m,s;
map<ll,int>re;
vector<bool>err;
cin>>k>>m;
s=ceil(sqrt(m))+1;
ll tmp=mult(9,k,m)+1,num=1,lin=1,at=1;
re[tmp]=0;
for(int B=1;B<=s;B++){
num=mult(10,num,m);
re[mult(tmp,num,m)]=B;
}
auto ke=re.find(1);
if(ke!=re.end()&&ke->second==0){
cout<<0;
return 0;
}
else
at=lin=qpow((ll)10,s,m);
for(int A=1;A<=s;A++){
if((ke=re.find(at))!=re.end()){
if(A*s-ke->second<0)cout<<err[4];
cout<<A*s-ke->second;
return 0;
}
at=mult(lin,at,m);
}
return 0;
}