Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int64_t step(int64_t tape, int64_t width, int64_t height){
- if(tape == 0){
- return 0;
- }
- if(tape >= width * height -1){
- return full(width, height);
- } else {
- if(width == 2){
- int64_t tapeHeightDiff = tape - height;
- if(tapeHeightDiff <= 0){
- return ((tape * tape * tape) -1);
- }
- return ((tape * tape * tape)-1 - (tapeHeightDiff*(tapeHeightDiff+1)));
- }
- int64_t sum = 0;
- for(int64_t i = 0; i < min(height, tape); i++){
- sum += (step(tape-i, width-1, height)) % mod;
- }
- if(min(height,tape) == tape){
- sum++ %mod;
- } else {
- sum += (step(tape-height,width-1,height)) % mod;
- }
- return sum % mod;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement