Advertisement
NAbdulla

hex a bonacci

Jul 2nd, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n, caseno = 0, cases, res, a, b, c, d, e, f;
  9.     scanf("%d", &cases);
  10.     while( cases-- ){
  11.         scanf("%d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &n);
  12.         if(n > 5){
  13.             n -= 5;
  14.             while(n--){
  15.                 res = (a%10000007 + b%10000007 + c%10000007 + d%10000007 + e%10000007 + f%10000007)%10000007;
  16.                 a = b;
  17.                 b = c;
  18.                 c = d;
  19.                 d = e;
  20.                 e = f;
  21.                 f = res;
  22.             }
  23.         }
  24.         else{
  25.             if( n == 0 ) res = a;
  26.             if( n == 1 ) res = b;
  27.             if( n == 2 ) res = c;
  28.             if( n == 3 ) res = d;
  29.             if( n == 4 ) res = e;
  30.             if( n == 5 ) res = f;
  31.         }
  32.         printf("Case %d: %d\n", ++caseno, res % 10000007);
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement