10:Rpg Game

Description

 

There are n cells in a sequence. You can use three kinds of colors, red , pink , green to paint these cells , one cell with only one kind of color . Promising that any two adjacent cells are painted with different colors and the color in the first cell is different from the color in the last cell . Now you need to calculate the total number of methods, meeting the given requirements, to paint these n cells.

 

Input

 

There are several test cases. Each test case is in one line with a integer N. (0 < n <= 50)

 

Output

 

For each test case, output the total number of the methods that meet the requirements. One answer a line , respectively.

 

Sample Input

 

1

2

Sample Output

 

3

6



package OJ;

import java.util.*;

public class P10_temp {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> al = new ArrayList<Integer>();
		while(true){
//			if(in.hasNextInt()){
				int n = in.nextInt();
				int num1 = 1;        //这一层为1的结点数
				int num = 0;        //这一层的结点数
				if(n == 1){
//					al.add(3);
					System.out.println(3);
				}
				else{
					for(int i=1; i<=n; i++){
						if(i == 1){
							num1 = 1;
							num = 1;
						}
						else{
							num1 = num - num1;
							num = num * 2;
						}
					}
//					al.add((num - num1)*3);
					System.out.println((num - num1)*3);
				}
				
//			}
//			else
//				break;		
		}
		
//		for(int i : al){
//			System.out.println(i);
//		}
		
	}

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值