Advertisement
Infernale

Fibonacci Sum

Jan 12th, 2019
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX 100005
  4. #define mod 1000000009
  5. int data[MAX];
  6.  
  7. void generate(){
  8.     for(int i=2;i<MAX;i++){
  9.         data[i] = data[i-2]%mod + data[i-1]%mod;
  10.     }
  11. }
  12.  
  13. int main(){
  14.     int tc, temp;
  15.     data[0] = 0;
  16.     data[1] = 1;
  17.     generate();
  18.     scanf("%d", &tc);
  19.     for(int i=1;i<=tc;i++){
  20.         scanf("%d", &temp);
  21.         printf("Case #%d: %d\n", i, (data[temp+2]-1)%mod);
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement