結果
| 問題 | No.2989 Fibonacci Prize |
| コンテスト | |
| ユーザー |
むつある
|
| 提出日時 | 2024-12-14 00:58:35 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 662 bytes |
| 記録 | |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 85,044 KB |
| 実行使用メモリ | 137,916 KB |
| 最終ジャッジ日時 | 2026-05-24 20:09:55 |
| 合計ジャッジ時間 | 4,725 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 74 WA * 3 |
ソースコード
n,m=map(int,input().split())
if n==1:
print((m-2)*(m-3)//2+m)
exit()
if m==1:
print(0)
exit()
if m==2:
print(0)
exit()
if m==3:
if n==2:
print(2)
else:
print(0)
exit()
loop=[0,1]
while True:
loop.append((loop[-1]+loop[-2]+1)%n)
if loop[-1]==loop[-2]==0:
break
loop=loop[1:]
cnt=[0]*n
cnt[0]=1
l=len(loop)
p=(m-2)//l
for i in loop:
cnt[i]+=p
for i in range((m-2)%l):
cnt[loop[i]]+=1
ans=0
last=(loop[(m-2)%l]-loop[(m-3)%l])%n
if last==0:
ans+=1
last=(loop[(m-2)%l]-loop[(m-4)%l])%n
if last==0:
ans+=1
last=(loop[(m-1)%l]-loop[(m-2)%l])%n
if last==0:
ans+=1
for i in cnt:
ans+=i*(i-1)//2
print(ans)
むつある