結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
|
提出日時 | 2022-07-22 23:30:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 307 bytes |
コンパイル時間 | 1,461 ms |
コンパイル使用メモリ | 159,196 KB |
実行使用メモリ | 42,164 KB |
最終ジャッジ日時 | 2024-07-04 08:21:26 |
合計ジャッジ時間 | 2,409 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define all(a) a.begin(),a.end() int main(){ ll n,m; cin >> n >> m; vector<ll> a(n); a[0]=0,a[1]=1; for(int i=2; i<n; ++i){ a[i]=(a[i-1]+a[i-2])%m; } cout << a[n-1] << endl; return 0; }