Saleh127

LO 1006

Jun 24th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long int x[200000],a, b, c, d, e, f;
  4. long long int fn( long long int n )
  5. {
  6. for(int i=0; i<=n; i++)
  7. {
  8. if( i == 0 )
  9. {
  10. x[i]=a;
  11. continue;
  12. }
  13. if( i == 1 )
  14. {
  15. x[i]=b;
  16. continue;
  17. }
  18. if( i == 2 )
  19. {
  20. x[i]=c;
  21. continue;
  22. }
  23. if( i == 3 )
  24. {
  25. x[i]=d;
  26. continue;
  27. }
  28. if( i == 4 )
  29. {
  30. x[i]=e;
  31. continue;
  32. }
  33. if( i == 5 )
  34. {
  35. x[i]=f;
  36. continue;
  37. }
  38. x[i] = x[i-1] + x[i-2] + x[i-3] + x[i-4] + x[i-5] + x[i-6];
  39. x[i] = x[i] % 10000007;
  40. }
  41. return x[n];
  42. }
  43. int main()
  44. {
  45. long long int n,i,cases;
  46. scanf("%lld",&cases);
  47. for(i=1; i<=cases; i++)
  48. {
  49. scanf("%lld %lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f, &n);
  50. printf("Case %lld: %lld\n",i,fn(n)%10000007);
  51. }
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment