結果
| 問題 |
No.2782 メルセンヌ数総乗
|
| コンテスト | |
| ユーザー |
Moss_Local
|
| 提出日時 | 2024-06-14 21:28:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 596 bytes |
| コンパイル時間 | 276 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-06-14 21:28:26 |
| 合計ジャッジ時間 | 1,362 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
def is_divisible_by_mn_plus_1(n):
# Compute M_n = 2^n - 1
m_n = (1 << n) - 1 # 1 << n is the same as 2^n
# Compute product of M_2 to M_(N+1)
product = 1
for i in range(2, n + 1):
product *= (1 << i) - 1
# Compute M_(N+1)
m_n_plus_1 = (1 << (n + 1)) - 1
# print(m_n_plus_1)
# print(product)
# Check if the product is divisible by M_(N+1)
if product % m_n_plus_1 == 0:
return "Yes"
else:
return "No"
# Read input
n = int(input())
# Get the result
result = is_divisible_by_mn_plus_1(n)
# Print the result
print(result)
Moss_Local