signedmain(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int A, B; std::cin >> A >> B; int max = 0; std::map<int, int> mp{{0, 1}, {6, 1}, {9, 1}, {8, 2}}; for (int i = A; i <= B; i++) { int t = i, cnt = 0; while (t) { cnt += mp[t % 10]; t /= 10; } max = std::max(max, cnt); } for (int i = A; i <= B; i++) { int t = i, cnt = 0; while (t) { cnt += mp[t % 10]; t /= 10; } if (cnt == max) { std::cout << i << "\n"; return0; } }
signedmain(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::map<int, int> cnt; for (int i = 1; i <= n; i++) { int x; std::cin >> x; cnt[x]++; } i64 ans = 1; for (int i = 1; i <= 1E6; i++) { if (cnt[i]) { ans = ans * (cnt[i] + 1) % P; } } std::cout << ans - 1 << "\n"; return0; }
constexprint P = 1E9 + 7; template <typename T> T power(T a, T b){ T res = 1; for (; b; b /= 2) { if (b & 1) res = res * a % P; a = a * a % P; } return res % P; }
int n, k; std::cin >> n >> k; std::vector<int> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } std::sort(a.begin(), a.end()); i64 ans = 0; int l = 0, r = n - 1; while (l < r) { if (a[l] + a[r] <= k) { ans += power(2, r - l) % P; ans %= P; l++; } else { r--; } } std::cout << ans << "\n"; return0; }
constexprint P = 1E9 + 7, inf = 0x3f3f3f3f; template <typename T> T power(T a, T b){ T res = 1; for (; b; b /= 2) { if (b & 1) { res = res * a % P; } a = a * a % P; } return res % P; }