-
-
Save tony01111299/3eda49d417b983627d4b0f94b4d256a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
int Fibo(int); | |
int main() | |
{ | |
int N, n; | |
scanf("%d", &N); | |
while(N--) | |
{ | |
scanf("%d", &n); | |
printf("%d\n", Fibo(n)); | |
} | |
} | |
int Fibo(int N) | |
{ | |
if(N <= 2) | |
return N>0; | |
int f1 = 1, f2 = 1; | |
N -= 2; | |
while(N--) | |
{ | |
f1 = f1+f2; | |
f2 = f1-f2; | |
if(f2 > 10000000) | |
{ | |
f1 -= 10000000; | |
f2 -= 10000000; | |
} | |
} | |
return f1%10000000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment