这题目给的测试用例不对,根本就没有点的总数。
Number Steps
https://www.nowcoder.com/practice/e3d8d4dd9ec740f9b1e7fc1e8574ba21
//Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
if (x == y || x == y + 2) {
if (x % 2 == 0) {
System.out.println(x + y);
} else {
System.out.println(x + y - 1);
}
} else {
System.out.println("No Number");
}
}
}
#Python
x, y = map(int, input().split())
if x == y or x == y + 2:
if x % 2 == 0:
print(x + y)
else:
print(x + y - 1)
else:
print('No Number')

查看5道真题和解析