Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
316838 xiang 守序数 T4 C++ 通过 37 MS 16752 KB 738 2026-04-16 20:10:38

Tests(10/10):


#include <iostream> #include <queue> using namespace std; int main() { int n; cin >> n; if (n <= 9) { cout << n << endl; return 0; } queue<long long> q; for (int i = 1; i <= 9; ++i) { q.push(i); } int count = 0; long long num = 0; while (!q.empty()) { num = q.front(); q.pop(); ++count; if (count == n) { cout << num << endl; break; } int last = num % 10; // 生成下一位可能的数字:last-1, last, last+1 for (int d = max(0, last - 1); d <= min(9, last + 1); ++d) { q.push(num * 10 + d); } } return 0; }


测评信息: