皮皮学,免费搜题
登录
搜题
【简答题】
阅读下面程序,当输入5 19时,程序输出是什么? #include #include #include using namespace std; int N, K; const int MAXN = 100000; int visited[MAXN + 10]; struct Step { int x; int steps; Step(int xx, int s) : x(xx), steps(s){} }; queue q; int main() { cin >> N >> K; memset(visited, 0, sizeof(visited)); q.push(Step(N, 0)); visited[N] = 1; while (!q.empty()) { Step s = q.front(); q.pop(); if (s.x == K) { cout << s.steps << endl; return 0; } else { if (s.x - 1 >= 0 && !visited[s.x - 1]) { q.push(Step(s.x - 1, s.steps + 1)); visited[s.x - 1] = 1; } if (s.x + 1 <= MAXN && !visited[s.x + 1]) { q.push(Step(s.x + 1, s.steps + 1)); visited[s.x + 1] = 1; } if (s.x * 2 <= MAXN && !visited[s.x * 2]) { q.push(Step(s.x * 2, s.steps + 1)); visited[s.x * 2] = 1; } } } return 0; }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【单选题】我国农产品农药残留超标的主要问题出在哪个环节?
A.
农药生产
B.
农药销售
C.
农药使用
D.
农药商品结构
【多选题】根据不同的齿廓曲线,普通圆柱蜗杆可分为
A.
阿基米德蜗杆
B.
渐开线蜗杆
C.
法向直廓蜗杆
D.
锥面包络蜗杆
【判断题】烯烃中的碳原子都采取 sp2 杂化 。
A.
正确
B.
错误
【判断题】对一棵二叉树进行层次遍历时,应借助于一个栈
A.
正确
B.
错误
【判断题】桃树的结果部位比较稳定。( )
A.
正确
B.
错误
【简答题】Matching the Chinese words with the corresponding English version.
【简答题】Matching the following pictures with the English name
【简答题】根据不同的齿廓曲线,普通圆柱蜗杆传动可以分为__、__、__、__等4种。
【简答题】Matching the Chinese expressions with the English ones
【简答题】Matching the following English with Chinese meaning.