# include
using namespace std;
Typedef long long ll;
Const int N=1 e6 + 100;
Struct node
{
Int x [N];
int len;
};
Int k, n;
Ll KSM (int a, int b)
{
if(! B) return 1;
Ll temp=KSM (a, b/2);
If (b % 2) return temp * temp * a;
Return temp * temp;
}
Ll get_num (int a [], int len)
{
Ll sum=0;
for(int i=1; i<=len; I++)
The sum +=KSM (k, a [I]);//, printf (" % d ", a [I]);
//printf (" \ n % LLD \ n ", sum);
return sum;
}
Void BFS ()
{
//printf (" 1 \ n ");
Priority_queue & lt; Int> Res.
Queueq;
The node t;
T.l en=1, t.x [1]=0;
Q.p ush (t);
//printf (" % d \ n ", q.e mpty ());
while(! Q.e mpty ())
{
The node now=q.f ront ();
Q.p op ();
//printf (" % d \ n ", now, len);
Ll w=get_num (now. X, now. Len);
Res. Push (w);
If (res) size ()==n)
{
Printf (" % LLD \ n ", res. The top ());
break;
}
For (int I=now. X [now. Len] + 1; i<=50; I++)
{
The node d;
D.l en=now. Len + 1;
D.x [d.l en]=I;
Q.p ush (d);
}
}
return ;
}
Int main ()
{
The scanf (" % d % d ", & amp; K, & amp; n);
//printf (" % d % d \ n ", k, n);
BFS ();
return 0;
}
CodePudding user response:
Input the two integers?CodePudding user response:
Your res generics for int, but in the long long, compile time also hint?CodePudding user response: