結果
| 問題 |
No.2989 Fibonacci Prize
|
| コンテスト | |
| ユーザー |
むつある
|
| 提出日時 | 2024-12-14 00:47:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 470 bytes |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 82,360 KB |
| 実行使用メモリ | 140,040 KB |
| 最終ジャッジ日時 | 2024-12-14 00:47:39 |
| 合計ジャッジ時間 | 6,457 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 42 |
ソースコード
n,m=map(int,input().split())
if m<2:
print(0)
exit()
if n==1:
print((m-2)*(m-3)//2+m)
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-1)%l]
if last==0:
ans+=1
last=loop[m%l]
if last==0:
ans+=1
for i in cnt:
ans+=i*(i-1)//2
print(ans)
むつある