daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int64_t step(int64_t tape, int64_t width, int64_t height){
  2.     if(tape == 0){
  3.         return 0;
  4.     }
  5.  
  6.     if(tape >= width * height -1){
  7.         return full(width, height);
  8.     } else {
  9.         if(width == 2){
  10.             int64_t tapeHeightDiff = tape - height;
  11.             if(tapeHeightDiff <= 0){
  12.                 return ((tape * tape * tape) -1);
  13.             }
  14.             return ((tape * tape * tape)-1 - (tapeHeightDiff*(tapeHeightDiff+1)));
  15.         }
  16.         int64_t sum = 0;
  17.         for(int64_t i = 0; i < min(height, tape); i++){
  18.             sum += (step(tape-i, width-1, height)) % mod;
  19.         }
  20.         if(min(height,tape) == tape){
  21.             sum++ %mod;
  22.         } else {
  23.             sum += (step(tape-height,width-1,height)) % mod;
  24.         }
  25.         return sum % mod;
  26.     }
  27. }
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