题库 信息学奥赛题库 题目列表 #include <iostream> using namespace std...
填空题

#include <iostream> 

using namespace std; 

int fun(int n, int fromPos, int toPos) { 

 int t, tot; 

    if (n == 0) 

     return 0; 

    for (t = 1; t <= 3; t++) 

        if (t != fromPos && t != toPos) 

            break; 

    tot = 0; 

    tot += fun(n - 1, fromPos, t); 

    tot++; 

    tot += fun(n - 1, t, toPos); 

    return tot; 

 

int main() { 

    int n; 

    cin >> n; 

    cout << fun(n, 1, 3) << endl; 

    return 0; 

输入:5

输出:_________

题目信息
2015年 初赛
-
正确率
0
评论
51
点击