now
```cpp
#include<iostream>
#include<map>
#include<cmath>
using namespace std;
#define ll __int128
map <ll,ll> vis;
ll qpmod(ll a,ll b,ll p){
ll ans=1%p;
while(b){
if(b&1) ans=ans*a%p;
a=a*a%p;
b>>=1;
}
return ans;
}
int main(){
long long B,P;
cin>>B>>P;
ll b=B,p=P;
ll a=10;
b=b*9+1;
b%=p;
a%=p;
ll num=sqrt(P);
vis[1]=0;
ll a_num=qpmod(a,num,p),now=a_num;
for(ll i=num;i<=p;i+=num){
vis[now]=i;
now=now*a_num%p;
}
now=1;
for(ll i=0;i<num;i++){
if(vis.count(b*now%p)){
cout<<(long long)(vis[b*now%p]-i);
return 0;
}
now=a*now%p;
}
cout<<"no solution";
}
```
by 1lgorithm @ 2021-11-15 19:16:01
@[1lgorithm](/user/287355) ~~话说60分就可以看别人的代码了~~
by lemon_qwq @ 2021-11-15 19:16:16