import java.util.HashSet;import java.util.Iterator;import java.util.Scanner;import java.util.Set;public class HihoCoder1546 {static int mod = 1000000007;static int count = 0;static Set<Integer> hasSet = new HashSet<Integer>();static int K = 0;static int z = 0;public static void main(String[] args) {Scanner in = new Scanner(System.in);int N = in.nextInt();K = in.nextInt();int[] num = new int[N];for (int i = 0; i < N; i++) {int value = in.nextInt();if (value <= K) {num[z] = value;z++;}}DSF(num, 0);System.out.println(count % mod);}private static boolean DSF(int[] num, int index) {if (index >= z && iSCheckOunt() && hasSet.size() > 0) {count++;return true;}for (int i = 1; i <= 2; i++) {if (index <= z && num[index] < K) {if (i == 1) {if (num[index] != 0) {hasSet.add(num[index]);}}DSF(num, index + 1);hasSet.remove(num[index]);}}return false;}private static boolean iSCheckOunt() {int max = 0;int min = 0;Iterator item = hasSet.iterator();int i = 0;while (item.hasNext()) {int a = (Integer) item.next();if (i == 0) {min = a;i++;}min = min < a ? min : a;max = max > a ? max : a;}if (min + max <= K && min > 0 && max > 0) {/*item = hasSet.iterator();while (item.hasNext()) {int a = (Integer) item.next();System.out.print(a + " ");}System.out.println();*/return true;}return false;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。