当前位置: 代码迷 >> 综合 >> HDOJ 1391 Number Steps
  详细解决方案

HDOJ 1391 Number Steps

热度:101   发布时间:2023-10-21 19:30:04.0

HD ACM 1391

如果有数,那么x ==y 或者 x==y+2,当x为奇数时,结果为x+y-1,否则为x+y;

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();while(n-->0){int x = sc.nextInt();int y = sc.nextInt();if (x ==y || x==y+2) {if (x%2==1) {System.out.println((x+y-1));}else{System.out.println((x+y));}continue;}System.out.println("No Number");}}
}
  相关解决方案