当前位置: 代码迷 >> 综合 >> HDOJ 1977 Consecutive sum II
  详细解决方案

HDOJ 1977 Consecutive sum II

热度:78   发布时间:2023-10-21 18:58:59.0

HDACM 1977

看题目可以发现规律,结果为 n^3 +(n+1)^3

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();while(t-->0){long n = sc.nextLong();System.out.println(n*n*n+" "+(n+1)*(n+1)*(n+1));}sc.close();}
}