#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 5010
#define H 123
#define INF 0x7f7f7f7f
#define LL long long
LL len,k,cnt,nk=0,mark,a[N<<5],ans[6],kmax[6]={0};
char s[5010];
void print(LL x){
if (x==0) return ;
if (x<H) printf("%c",x);
else {
print((x-(x%H))/H);
if (x%H) printf("c",x%H);
}
}
int main()
{
scanf("%s",s);
scanf("%d",&k);
LL mmax = 1;
for (LL i=1;i<=5;i++) mmax*=H;
len = strlen(s);
memset(a,0x7f7f7f7f,sizeof(a));
for (int i=0;i<len;i++){
a[++cnt] = (int)(s[i]);
for (int j=1;i+j<len && j<=4;j++)
a[++cnt] = a[cnt-1] *H + (int)(s[i+j]);
}
for (int i=1;i<=cnt;i++)
while (a[i]<mmax) a[i]*=H;
sort(a+1,a+cnt+1);
for (int i=1;i<=cnt;i++){
mark = 1;
for (int j=1;j<=5;j++)
if (a[i]==kmax[j]) mark = 0;
if (mark) kmax[++nk] = a[i];
if (nk==k) break;
}
int x = 0;
while (kmax[k]>0){
ans[++x] = kmax[k]%H;
kmax[k] = (kmax[k]-ans[x])/H;
}
for (int i=6;i>0;i--){
if (ans[i]==0) break;
printf("%c",ans[i]);
}
return 0;
}
./Main.cpp: In function ‘void print(long long int)’:
./Main.cpp:18:24: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
if (x<H) printf("%c",x);
^
./Main.cpp:21:26: warning: too many arguments for format [-Wformat-extra-args]
if (x%H) printf("c",x%H);
^
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:15: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
scanf("%d",&k);
^
./Main.cpp:54:21: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
printf("%c",ans[i]);
^
./Main.cpp:26:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s);
^
./Main.cpp:27:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute w...