提交时间:2026-04-22 17:09:43
运行 ID: 318265
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; queue<ll> q; for (int i = 1; i <= 9; ++i) { q.push(i); } ll ans = 0; int cnt = 0; while (!q.empty()) { ll cur = q.front(); q.pop(); cnt++; if (cnt == n) { ans = cur; break; } int last = cur % 10; for (int d = -1; d <= 1; ++d) { int next_d = last + d; if (next_d >= 0 && next_d <= 9) { q.push(cur * 10 + next_d); } } } cout << ans << endl; return 0; }