题解 | #牛牛学数列6#
牛牛学数列6
https://ac.nowcoder.com/acm/problem/22161
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
System.out.println(fun(n));
}
public static int fun(int n){
if(n == 1){
return 0;
}else if(n == 2 || n == 3){
return 1;
}
return fun(n - 3) + 2 * fun(n - 2) + fun(n - 1);
}
}