题解 | #尼科彻斯定理#
尼科彻斯定理
https://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); int zs = fzhinput.nextInt(); int zsscf = zs*zs*zs; int zjz = zsscf/zs; int array[] = new int[zs]; if(zs%2==0){ int z1 =zjz-1; int z2 =zjz+1; for(int i=zs/2-1;i>=0;i--){ array[i]=z1; z1-=2; } for(int i=zs/2;i<zs;i++){ array[i]=z2; z2+=2; } Arrays.sort(array); for(int i=0;i<zs;i++){ System.out.print(array[i]); if(i!=zs-1){ System.out.print("+"); } } } else{ int z1=zjz; int z2=zjz+2; for(int i=zs/2;i>=0;i--){ array[i]=z1; z1-=2; } for(int i=zs/2+1;i<zs;i++){ array[i]=z2; z2+=2; } Arrays.sort(array); for(int i=0;i<zs;i++){ System.out.print(array[i]); if(i!=zs-1){ System.out.print("+"); } } } } }