尼科彻斯定理
尼科彻斯定理
http://www.nowcoder.com/questionTerminal/dbace3a5b3c4480e86ee3277f3fe1e85
import java.util.Scanner;
public class Main
{
public String getSequeOddNum(int m)
{
int low;
if (m % 2 != 0) {
low = m * m - 2*(m/2);
}
else {
low = m * m - 1 - (m-1)/2*2;
}
StringBuilder s = new StringBuilder().append(low);
for (int i = 1; i < m; i++) {
s.append("+").append(low + i*2);
}
return s.toString();
}
public Main()
{
Scanner in = new Scanner(System.in);
while (in.hasNextInt())
{
int m = in.nextInt();
String result = getSequeOddNum(m);
System.out.println(result);
}
}
public static void main(String[] args)
{
Main solution = new Main();
}
}
查看27道真题和解析