View Code of Problem 3834

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		while(in.hasNext()) {
			int n =in.nextInt();
			int[] ou = new int[n];
			int[] ji = new int[n];
			ou[0]=2;
			ji[0]=1;
			for(int i =1;i<n;i++) {
				ou[i]=2*ou[i-1]+ji[i-1];
				ji[i]=2*ji[i-1]+ou[i-1];
			}
			System.out.println(ou[n-1]);
		}
	}
}

Double click to view unformatted code.


Back to problem 3834