結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー teasnon
提出日時 2025-01-28 00:03:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 160,632 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-28 00:04:02
合計ジャッジ時間 2,856 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<endl;for(auto i:v)os<<i<<" ";return os;}
const ll inf=(1LL<<60);
#define all(a) (a).begin(),(a).end()
int main(){
  cin.tie(0)->sync_with_stdio(0);
  ll n,m;
  cin>>n>>m;
  ll a=0,b=1,c=1;
  for(ll i=0;i<n-3;i++){
  	swap(a,b);
  	swap(b,c);
  	c=(a+b)%m;
  }
  cout<<c<<endl;
  char crlf;cin>>crlf;assert(cin.eof());
}
0