結果
| 問題 |
No.793 うし数列 2
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-09-30 02:10:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 942 bytes |
| コンパイル時間 | 1,040 ms |
| コンパイル使用メモリ | 104,948 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 02:10:37 |
| 合計ジャッジ時間 | 2,030 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#include<atcoder/modint>
using mint = atcoder::modint1000000007;
#include<array>
const int B = 2;
using dat = array<array<mint,2>,2>;
dat op(dat a,dat b){
dat now{};
for(int i = 0;i<B;i++) for(int j = 0;j<B;j++) for(int k = 0;k<B;k++) now[i][j] += a[i][k] * b[k][j];
return now;
}
dat e(){
dat now{};
for(int i = 0;i<B;i++) now[i][i] = 1;
return now;
}
dat mpow(dat a,ll k){
dat u = e();
while(k){
if(k&1) u = op(u,a);
a = op(a,a);
k >>= 1;
}
return u;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n;
cin>>n;
//mint ans = 1;
dat a{};
a[0][0] = 10;
a[0][1] = 3;
a[1][1] = 1;
a = mpow(a,n);
vector<mint> now(2);
now[0] = 1;
now[1] = 1;
mint ans = a[0][0] + a[0][1];
cout<<ans.val()<<endl;
}
momoyuu