結果
| 問題 |
No.534 フィボナッチフィボナッチ数
|
| コンテスト | |
| ユーザー |
TangentDay
|
| 提出日時 | 2017-06-24 00:04:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,214 bytes |
| コンパイル時間 | 720 ms |
| コンパイル使用メモリ | 89,432 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-03 03:55:26 |
| 合計ジャッジ時間 | 1,659 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 21 |
ソースコード
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
vector<VL> mulmat(vector<VL> A, vector<VL> B, ll mod){
int n = A.size();
vector<VL> C(n, VL(n));
REP(i,n) REP(j,n) REP(k,n) C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
return C;
}
vector<VL> powmat(vector<VL> A, ll x, ll mod){
int n = A.size();
vector<VL> B(n, VL(n));
REP(i,n) B[i][i] = 1;
while (x){
if (x & 1) B = mulmat(B, A, mod);
A = mulmat(A, A, mod);
x >>= 1;
}
return B;
}
int main() {
ll n;
cin >> n;
vector<VL> A(2,VL(2,1));
A[1][1] = 0;
A = powmat(A, n, 2e9 + 17);
ll fi = A[1][0];
// cout << fi<< endl;
A[0][0] = A[0][1] = A[1][0] = 1;
A[1][1] = 0;
A = powmat(A, fi, 1e9 + 7);
cout << A[1][0] << endl;
return 0;
}
TangentDay