-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem 25.cpp
More file actions
45 lines (39 loc) · 822 Bytes
/
Problem 25.cpp
File metadata and controls
45 lines (39 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//ANSWER IS 4782
//EXECUTION PROCESS TAKES 1.656 SECONDS
#include<iostream>
using namespace std;
int main()
{
long long index=2;
int a[1001],i,j,k,b[1001],c[1001];
for(i=0;i<1001;i++)
{
a[i]=0;
b[i]=0;
c[i]=0;
}
a[1]=1;
b[1]=1;
int d=1;
while(d<1000)
{
index++;
for(i=1;i<=d;i++)
c[i]=b[i];
k=0;
for(i=1;i<=d;i++)
{
k=a[i]+b[i]+k;
b[i]=k%10;
k=k/10;
if(i==d&&k>0)
d++;
}
for(i=1;i<=d;i++)
a[i]=c[i];
// for(i=d;i>=1;i--)
// cout<<b[i];
cout<<d<<"\n";
}
cout<<index;
}