mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:52:02 +00:00
P4994 终于结束的起点
R38706118
This commit is contained in:
parent
778250ab66
commit
e676c04e15
37
problem/P4994/P4994.cpp
Normal file
37
problem/P4994/P4994.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// R38706118
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
long long a[10000000];
|
||||
|
||||
long long dfib(long long x, long long m) {
|
||||
if (a[x] != -1) {
|
||||
return a[x];
|
||||
}
|
||||
if (x == 0) {
|
||||
a[x] = 0 % m;
|
||||
return 0;
|
||||
}
|
||||
if (x == 1) {
|
||||
a[x] = 1 % m;
|
||||
return 1;
|
||||
}
|
||||
a[x] = (dfib(x - 1, m) + dfib(x - 2, m)) % m;
|
||||
return a[x];
|
||||
}
|
||||
|
||||
int main() {
|
||||
long long m;
|
||||
memset(a, 0xff, sizeof(a));
|
||||
cin >> m;
|
||||
for (int i = 2; i < m * m; i++) {
|
||||
// cout << i << ' ' << dfib(i, m) << endl;
|
||||
if (dfib(i, m) == 0 && dfib(i + 1, m) == 1) {
|
||||
cout << i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user