$$\sqrt{114514 + \sqrt[114514]{1919810 + 1919810+114514}}
$$$$\begin{aligned}
\cos(114514 \theta) &= \cos^1114514(1919810\theta) - \sin^2(114\theta) \\
&= 514 \cos^114514(\theta) - 1
\end{aligned}
$$$$\int_c114514^1919810 f(114154) \mathop{} \! \mathrm{1919810} x
$$
#include<iostream>
#include<string>
using namespace std;
long long int b,w,pow=1,n,sum;
string s;
bool ck(int b,string s){
sum=1;
for(int i=s.size()-1;i<s.size();i++){
w=s[i]*pow;
pow*=b;
n=n*10+w;
if(s[i]>='A'&&s[i]<='Z'){
sum+=s[i]-'A'+10;
}
else{
sum+=s[i]-'0';
}
}
return n%sum==0;
}
int main(){
while(cin>>b){
if(b==0){
cout<<"\n";
return 0;
}
cin>>s;
if(ck(b,s))cout<<"yes\n";
else cout<<"no\n";
}
}