結果
| 問題 |
No.237 作図可能性
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:14:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 1,016 bytes |
| コンパイル時間 | 499 ms |
| コンパイル使用メモリ | 82,512 KB |
| 実行使用メモリ | 53,652 KB |
| 最終ジャッジ日時 | 2025-03-20 21:15:15 |
| 合計ジャッジ時間 | 2,001 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
fermat_primes = [3, 5, 17, 257, 65537]
def compute_max_m(s, A):
if s == 0:
return -1
target = A // s
if target == 0:
return -1
m = 0
current = 1
while current * 2 <= target:
current *= 2
m += 1
return m
A = int(input())
count = 0
for mask in range(0, 1 << 5): # There are 5 Fermat primes
product = 1
for j in range(5):
if mask & (1 << j):
product *= fermat_primes[j]
if product > A:
break # Early exit if product exceeds A
if product > A:
continue # Skip products exceeding A
if product == 1:
# Handle case where product is 1 (empty subset)
# We need m >= 2 (since n = 2^m must be >=3)
max_exp = compute_max_m(1, A)
if max_exp >= 2:
count += (max_exp - 2 + 1)
else:
# For other products, compute valid m
max_exp = compute_max_m(product, A)
if max_exp >= 0:
count += (max_exp + 1)
print(count)
lam6er