Skip to content

Instantly share code, notes, and snippets.

@tony01111299
Created April 20, 2016 09:15
Show Gist options
  • Save tony01111299/3eda49d417b983627d4b0f94b4d256a7 to your computer and use it in GitHub Desktop.
Save tony01111299/3eda49d417b983627d4b0f94b4d256a7 to your computer and use it in GitHub Desktop.
#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