Українська
Відкрити в Telegram

Гілкаpy da tl olyapti:

22 повідомлення · –
#
py da tl olyapti: def foo(a: int, b: int) -> int: x: list = [] y: str = "" d: int = 0 for i in range(a, b + 1): s = bin(i)[2:] x.append(s) y += s if len(y) % 2 == 0 and y.count('1') == y.count('0'): d += 1 else: y = "" return d a,b = map(int,input().split()) print(foo(a,b))
  1. #
    buni ozim yozdim time limit oganiga cpp ga ogirdim
    1. J
      Ha bunaqa standartda yozishni qayerdan oʻrgangansiz?
      1. #
        yani nima s: int = 0 shunga oxshashmi
        1. J
          Фотографія
          натисніть — покажемо
  2. #
    shuni qayerini ozgartirish kere tl omaslik uchun yo umuman boshqa algodan foydalanish keremi?
              1. 4
                qisqa kodlariz o'tmaydi baribir
                      1. 4
                        MOD = 10**9 + 7 class Mint: def init(self, value=0): if isinstance(value, Mint): self.value = value.value else: self.value = value % MOD if self.value < 0: self.value += MOD def int(self): return self.value def iadd(self, other): if isinstance(other, Mint): self.value += other.value else: self.value += other if self.value >= MOD: self.value -= MOD return self def isub(self, other): if isinstance(other, Mint): self.value -= other.value else: self.value -= other if self.value < 0: self.value += MOD return self def imul(self, other): if isinstance(other, Mint): self.value = self.value * other.value % MOD else: self.value = self.value * other % MOD return self def itruediv(self, other): if isinstance(other, Mint): self.value = self.value * pow(other.value, MOD - 2, MOD) % MOD else: self.value = self.value * pow(other, MOD - 2, MOD) % MOD return self def add(self, other): res = Mint(self.value) res += other return res def sub(self, other): res = Mint(self.value) res -= other return res def mul(self, other): res = Mint(self.value) res *= other return res def truediv(self, other): res = Mint(self.value) res /= other return res def repr(self): return str(self.value) def get_bin_digits(x): ret = [] while x > 0: ret.append(x % 2) x >>= 1 return ret[::-1] def solve(): import sys input = sys.stdin.read data = input().strip().split() n = int(data[0]) m = int(data[1]) def dp(pos, dif, any, lead, M): if pos == len(M): return Mint(0) if lead else Mint(1) if dif == 0 else Mint(0) if used[pos][dif + offset][any][lead]: return memo[pos][dif + offset][any][lead] used[pos][dif + offset][any][lead] = True max_digit = 1 if any else M[pos] ans = Mint(0) for digit in range(max_digit + 1): new_any = any or (digit < max_digit) new_lead = lead and (digit == 0) new_dif = dif + 1 if digit == 1 else dif - (0 if lead else 1) ans += dp(pos + 1, new_dif, new_any, new_lead, M) memo[pos][dif + offset][any][lead] = ans return ans N = get_bin_digits(n - 1) M = get_bin_digits(m) offset = 60 used = [[[[False] * 2 for _ in range(2)] for _ in range(129)] for _ in range(65)] memo = [[[[Mint(0)] * 2 for _ in range(2)] for _ in range(129)] for _ in range(65)] ans = dp(0, 0, False, True, M) if n - 1 > 0: M = N used = [[[[False] * 2 for _ in range(2)] for _ in range(129)] for _ in range(65)] memo = [[[[Mint(0)] * 2 for _ in range(2)] for _ in range(129)] for _ in range(65)] ans -= dp(0, 0, False, True, M) print(ans) if name == "main": solve()

Відкрита публічна стрічка з пошукового індексу ChatCrawler — «Google по публічному Telegram»; оновлюється в міру обходу майданчика. Час — UTC.

Лише публічний контент, офіційний API Telegram. Про проєкт · Питання · Межі індексу · Прибрати сторінку з видачі · Каталог · Пошук · Як ми рахуємо