-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem25.cpp
More file actions
52 lines (47 loc) · 910 Bytes
/
Problem25.cpp
File metadata and controls
52 lines (47 loc) · 910 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
46
47
48
49
50
51
52
/*
Krishna Mohan
Project Euler - Problem 25
Date: 3/18/2015
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int (i)=0;(i)<(n); (i)++)
#define MAX 2000
int a[MAX], b[MAX], c[MAX];
int main()
{
ios_base::sync_with_stdio(0);
int len=1, carry, term=1;
a[0]=0;
b[0]=1;
while(len<1000)
{
carry=0;
fo(i, len)
{
c[i]=a[i]+b[i]+carry;
carry=c[i]/10;
c[i]%=10;
}
while(carry)
{
c[len++]=carry%10;
carry/=10;
}
term++;
fo(i, len)
{
a[i]=b[i];
}
fo(i, len)
b[i]=c[i];
/*for(int i=len-1; i>=0;i--)
cout<<c[i];
cout<<endl;*/
}
/* for(int i=len-1; i>=0;i--)
cout<<c[i];
cout<<endl;*/
cout<<term<<endl;
return 0;
}