結果

問題 No.303 割れません
ユーザー gew1fw
提出日時 2025-06-12 19:48:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 83,620 KB
最終ジャッジ日時 2025-06-12 19:49:01
合計ジャッジ時間 2,545 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7
max_n = 3 * 10**6

# Precompute the number of compositions into odd parts
c = [0] * (max_n + 2)
if max_n >= 1:
    c[1] = 1
if max_n >= 2:
    c[2] = 1

for n in range(3, max_n + 1):
    c[n] = (c[n-1] + c[n-2]) % MOD

L = int(input())

if L % 2 == 1:
    cost = L
    ways = c[L] % MOD
else:
    cost = L
    half = L // 2
    c_half = c[half]
    ways = (c[L] - (c_half * c_half) % MOD) % MOD
    ways = (ways + MOD) % MOD  # Ensure non-negative

print(cost)
print(ways)
0