这是 2026-10-23 的上一版评测(LiveCodeBench 最新 35 题)。最新的阶梯评测见 首页。
结果
Kimi K3.1 ProKimi
✓
通过
- 函数调用,官方测试全部通过判题
- 6.4k输出 token(含思考) ↓
- 99 秒延迟 ↓
- 0.11 秒(最快)最慢测试的 CPU 时间 ↓
- 26 MB峰值内存 ↓
- 6Pylint 问题 ↓
- 7.39Pylint 得分 ↑
- 3圈复杂度 ↓
- 61.9可维护性指数 ↑
- 37有效行
- 2SonarQube 问题 ↓
DeepSeek-V4.1-FlashDS-Flash
✓
通过
- 函数调用,官方测试全部通过判题
- 3.8k输出 token(含思考) ↓
- 22 秒延迟 ↓
- 0.11 秒最慢测试的 CPU 时间 ↓
- 26 MB峰值内存 ↓
- 6Pylint 问题 ↓
- 7.39Pylint 得分 ↑
- 3圈复杂度 ↓
- 51.6可维护性指数 ↑
- 25有效行
- 2SonarQube 问题 ↓
DeepSeek-V4-ProDS-Pro
✓
通过
- 函数调用,官方测试全部通过判题
- 66.3k输出 token(含思考) ↓
- 474 秒延迟 ↓
- 0.93 秒(8.3×)最慢测试的 CPU 时间 ↓
- 18 MB峰值内存 ↓
- 14Pylint 问题 ↓
- 8.21Pylint 得分 ↑
- 5圈复杂度 ↓
- 55.0可维护性指数 ↑
- 81有效行
- 4SonarQube 问题 ↓
↑ 越大越好,↓ 越小越好,有效行只描述代码长短。CPU 时间与内存只统计能区分性能的题(最慢答案扣除进程启动后仍 ≥ 0.1 秒),括号内为相对最快者的倍数(≥ 2 时标出)。静态质量按 arXiv:2610.19167 的口径(见 原理)。判题方法见 原理 › 判题。
代码
Kimi K3.1 Pro · 48 行
from functools import lru_cache class Solution: def beautifulNumbers(self, l: int, r: int) -> int: def count_up_to(x: int) -> int: if x <= 0: return 0 digits = [int(c) for c in str(x)] n = len(digits) @lru_cache(None) def dfs( pos: int, digit_sum: int, digit_product: int, started: bool, tight: bool, ) -> int: if pos == n: if not started: return 0 return int(digit_product % digit_sum == 0) limit = digits[pos] if tight else 9 total = 0 for d in range(limit + 1): next_tight = tight and d == digits[pos] if not started and d == 0: # Leading zero: the number has not started yet. total += dfs(pos + 1, 0, 1, False, next_tight) else: total += dfs( pos + 1, digit_sum + d, digit_product * d, True, next_tight, ) return total return dfs(0, 0, 1, False, True) return count_up_to(r) - count_up_to(l - 1)
DeepSeek-V4.1-Flash · 34 行
from functools import lru_cache class Solution: def beautifulNumbers(self, l: int, r: int) -> int: def count(n: int) -> int: if n <= 0: return 0 digits = list(map(int, str(n))) length = len(digits) @lru_cache(None) def dp(pos: int, digit_sum: int, digit_product: int, tight: bool, started: bool) -> int: if pos == length: return 1 if started and digit_product % digit_sum == 0 else 0 limit = digits[pos] if tight else 9 total = 0 for d in range(limit + 1): next_tight = tight and (d == digits[pos]) if not started and d == 0: total += dp(pos + 1, digit_sum, digit_product, next_tight, False) elif not started: total += dp(pos + 1, d, d, next_tight, True) else: total += dp(pos + 1, digit_sum + d, digit_product * d, next_tight, True) return total return dp(0, 0, 1, True, False) return count(r) - count(l - 1)
DeepSeek-V4-Pro · 107 行
class Solution: def beautifulNumbers(self, l: int, r: int) -> int: def count_no_zero_upto(n: int) -> int: """Count positive integers <= n with no digit 0.""" if n <= 0: return 0 s = str(n) L = len(s) total = 0 for m in range(1, L): total += 9 ** m for i, ch in enumerate(s): digit = ord(ch) - 48 rem = L - i - 1 if digit > 0: total += (digit - 1) * (9 ** rem) else: break else: total += 1 return total def build_ways(S: int, max_len: int): """ ways[rem][sum][prod] = number of completions of length rem (digits 1..9, no zero) such that final digit sum is S and final product is divisible by S (i.e. prod modulo S becomes 0). """ mul = [[(p * d) % S for d in range(10)] for p in range(S)] prev = [[0] * S for _ in range(S + 1)] prev[S][0] = 1 ways = [prev] for _ in range(1, max_len): cur = [[0] * S for _ in range(S + 1)] for s in range(S + 1): max_d = min(9, S - s) if max_d <= 0: continue for p in range(S): total = 0 for d in range(1, max_d + 1): total += prev[s + d][mul[p][d]] cur[s][p] = total ways.append(cur) prev = cur return ways def count_zf_beautiful_upto(n: int, S: int, ways) -> int: """Count zero-free beautiful numbers <= n with digit sum S.""" if n <= 0: return 0 s = str(n) L = len(s) start_prod = 1 % S ans = 0 # All shorter lengths are automatically <= n. for m in range(1, L): ans += ways[m][0][start_prod] cur_sum = 0 cur_prod = start_prod for i, ch in enumerate(s): limit = ord(ch) - 48 rem = L - i - 1 # Put a smaller non-zero digit here; the rest can be anything. for d in range(1, limit): ns = cur_sum + d if ns <= S: np = (cur_prod * d) % S ans += ways[rem][ns][np] # Continue with the exact digit of n. if limit == 0: break if cur_sum + limit > S: break cur_sum += limit cur_prod = (cur_prod * limit) % S else: if cur_sum == S and cur_prod == 0: ans += 1 return ans # Any number containing a zero is beautiful: product = 0. total_range = r - l + 1 zf_range = count_no_zero_upto(r) - count_no_zero_upto(l - 1) zero_containing = total_range - zf_range max_len = len(str(r)) max_sum = 9 * max_len zf_beautiful_r = 0 zf_beautiful_lm = 0 for S in range(1, max_sum + 1): ways = build_ways(S, max_len) zf_beautiful_r += count_zf_beautiful_upto(r, S, ways) zf_beautiful_lm += count_zf_beautiful_upto(l - 1, S, ways) zero_free_beautiful = zf_beautiful_r - zf_beautiful_lm return zero_containing + zero_free_beautiful