本文主要是介绍蓝桥小白赛4 乘飞机 抽屉原理 枚举,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
👨🏫 乘飞机
🐷 抽屉原理
import java.util.Scanner;public class Main
{static int N = 100010;static int[] a = new int[N];public static void main(String[] args){Scanner sc = new Scanner(System.in);int n = sc.nextInt();int q = sc.nextInt();for (int i = 1; i <= n; i++)a[i] = sc.nextInt();while (q-- > 0){int l = sc.nextInt();int r = sc.nextInt();if (r - l >= 100)System.out.println("YES");elsecal(l, r);}}private static void cal(int l, int r){boolean res = false;for (int i = l; i <= r; i++)for (int j = i + 1; j <= r; j++)if (Math.abs(a[i] - a[j]) <= 365){System.out.println("YES");return;}System.out.println("NO");}
}
这篇关于蓝桥小白赛4 乘飞机 抽屉原理 枚举的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!