https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=11&problem=854&mosmsg=Submission+received+with+ID+17585410 困難度 ★ 首先先找到行數跟那行有幾個值的關係求得行數再來透過行數找出最後一個值
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner (System.in);
while(scn.hasNext()){
long tot=0,n=scn.nextLong();
tot=(n+1)/2;
tot=tot*tot*2-1;
System.out.println(tot*3-6);
}
}
/*
題目:Q913: Joana and the Odd Numbers
作者:1010
時間:西元 2016 年 6 月 */
}