結果
| 問題 |
No.2989 Fibonacci Prize
|
| コンテスト | |
| ユーザー |
chestnut_68
|
| 提出日時 | 2024-12-14 08:42:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 592 bytes |
| コンパイル時間 | 1,949 ms |
| コンパイル使用メモリ | 171,156 KB |
| 実行使用メモリ | 798,328 KB |
| 最終ジャッジ日時 | 2024-12-14 08:43:18 |
| 合計ジャッジ時間 | 23,220 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 64 WA * 4 TLE * 4 MLE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,T=-1,MAX=1e9;
cin>>N>>M;
vector<int> F(3);
vector<int64_t>R(N,0),RR(N,0);
F[1]=F[2]=1;
for(int i=3;i<MAX;i++){
F.push_back((F[i-1]+F[i-2])%N);
if(F[i-1]==0&&F[i]==1){
T=i-1;
break;
}
}
F.push_back(1);
for(int i=1;i<=T;i++){
R[(F[i+2]-1+N)%N]++;
}
int64_t K=(M-2)/T,r=(M-2)%T;
for(int i=1;i<=r;i++){
RR[(F[i+2]-1+N)%N]++;
}
RR[0]++;
int64_t ans=0;
for(int i=0;i<N;i++){
R[i]*=K;
R[i]+=RR[i];
ans+=R[i]*(R[i]-1)/2;
}
if(F[(M-1)%T]%N==0)ans++;
if(F[M%T]%N==0)ans+=2;
cout<<ans<<endl;
}
chestnut_68