C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
31
1
2
3
4
using std::cin;
5
using std::vector;
6
7
int fibrecursion(int num,vector<int>&store)
8
9
{
10
11
if(store[num]!=0)return store[num];
12
if(num==1||num==2)return 1;
13
14
int ans=fibrecursion(num-1,store)+fibrecursion(num-2,store);
15
ans=ans%(int(pow(10,9))+7);
16
store[num]=ans;
17
return ans;
18
}
19
20
int main()
21
22
{
23
24
int A;
25
cin>>A;
26
vector<int>store(A+1,0);
27
store[1]=store[2]=1;
28
return fibrecursion(A,store);
29
30
}
31
$ g++ prog.cc -Wall -Wextra -std=c++11
Stdin
10
Start
55
Finish