这题无解😭😭😭
2024-08-06 10:36:30
发布于:湖南
60阅读
0回复
0点赞
我都用上矩阵了😡😡😡
#include <iostream>
#include <cstdio>
#define int unsigned long long
using namespace std;
const int mod = 1e9+7;
struct node{
	int fib[2][2] = {{0, 0}, {0, 0}};
	node operator * (const node &b) const{
		node temp;
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				for(int k = 0; k < 2; k++) temp.fib[i][j] = (temp.fib[i][j] + fib[i][k] * b.fib[k][j] % mod) % mod;
			}
		}return temp;
	} 
}a, b;
signed main(){
	a.fib[0][0] = a.fib[1][0] = a.fib[0][1] = 1;
    b.fib[0][0] = b.fib[1][1] = 1;
	int n;
	cin >> n;
    for(int i = 1; i <= n; i++){
        b = b * a;
    }
    
	cout << b.fib[0][1];
	return 0;
}
全部评论 2
😭😭😭
2024-08-06 来自 湖南
0谁能告诉我为什么😭😭😭我都用矩阵了
2024-08-05 来自 湖南
0







有帮助,赞一个