题解 | #尼科彻斯定理#
尼科彻斯定理
http://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int i = sc.nextInt();
System.out.println(getExpress(i));
}
}
public static String getExpress(int n){
int sum=0;
int add=0;
for(int i=1;i<n;i++){
add=add+2;
sum=sum + add;
String str=start+"";
for(int i=1;i<n;i++){
start =start+2;
str=str+"+"+start;
}
return str;
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int i = sc.nextInt();
System.out.println(getExpress(i));
}
}
public static String getExpress(int n){
int sum=0;
int add=0;
for(int i=1;i<n;i++){
add=add+2;
sum=sum + add;
}
//计算出开始的数,然后每次加2拼接字符串
int start = (n*n*n-sum)/n;String str=start+"";
for(int i=1;i<n;i++){
start =start+2;
str=str+"+"+start;
}
return str;
}
}