daily pastebin goal
24%
SHARE
TWEET

Fibonacci Sum

Infernale Jan 12th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top