给你一个斐波那契数字,让你求出是第几项
解析:只需在预处理中将所有数字对1e9+7取模,然后将给定的数字取模,用map进行匹配即可
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int N = (int) 100000 + 11;
const int M = (int) 1e6 + 11;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 0x3f3f3f3f;
ull f[N]={0,1};
map<ull, int> mp;
int main(){
mp[1] = 1; mp[0] = 0;
for(int i = 2; i < N; i++){
f[i] = (f[i-1] + f[i-2])%MOD;
mp[f[i]] = i;
}
int T; cin>>T;
while(T--){
string s; cin>>s;
ull ans=0;
for(int i = 0; s[i]; i++) ans = (ans * 10 + s[i] - '0')%MOD;
cout<<mp[ans]<<"\n";
}
return 0;
}