#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define x first
#define y second
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N=1e6 + 10,M =60000, INF = 0x3f3f3f3f ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
int n,m;
struct node{
int a,b;// a -> 位置,b->各个位置上的和
bool operator<(const node &W) const
{
if(b != W.b) return b < W.b;
return a <W.a;
}
}q[N];
void solve()
{
cin >> n >> m ;
int t;
for(int i=1;i<=n;i ++ )
{
q[i].a=i;int t =i;
while(t) q[i].b+= t % 10,t /=10;
}
sort(q+1,q+1+n);
cout <<q[m].a << endl;
}
signed main()
{
// freopen("1.txt","r",stdin);
ios
LL T=1;
// cin>>T;
int now = 1;
while(T -- )
{
// cout<<"Case ";
// cout<< now ++ <<": ";
solve();
}
return 0;
}
数位排序(排序)(蓝桥云课)
最新推荐文章于 2023-03-18 20:51:25 发布