你好!这里是椰子海.&coconut11!!虽然已经来CSDN快两年了但是第一次发博客好像(dbq是我太菜了致歉)and后面应该会常发!
srds是记录学习过程,srds其实不是第一天接触编程。没关系!今天就记录杭电oj的T2045(今天不止这一道但是懒得记录别的了(bushi))
题目和内心os如上
我的解答如下
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
long n = input.nextLong();
long s=0;
int x=6;
if(n==1){
System.out.println(3);
}
else if(n==2){
System.out.println(6);
}
else if(n==3) {
System.out.println(6);
}
else {
s=6;
for (int i = 4; i <= n; i++) {
s = s * 2 + x;
x = -x;
}
System.out.println(s);
}
}
}
}
那么!今天就到这里啦!晚安!