Codeforces Round #394 (Div. 2) - A
题目链接:http://codeforces.com/contest/761/problem/A
题意:给定a个偶数,b个奇数,问是否能构成奇偶相间的阶梯。
思路:a和b相差小于等于1即可构造出来。特判 a=0,b=0.
import java.io.PrintWriter; import java.util.*; public class Main { public static final int MAXN=100000+5; public static int v[]=new int [MAXN]; public static void main(String[] args) { Scanner cin = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n=cin.nextInt(),m=cin.nextInt(); out.println(Math.max(n,m)-Math.min(n,m)<=1&&(n>0||m>0)?"YES":"NO"); cin.close(); out.flush(); } }