Advertisement
florence20

Untitled

Apr 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public long afisare(){
  2. long aux = 0;
  3. dp = new long[lungime][lungime];
  4. dp[1][0] = 1;
  5. for(int j = 1; j < lungime; j++){
  6. for(int i = 0; i < lungime; i++){
  7. if(charachets[j] == '^'){
  8. if(i == 0) {
  9. aux = dp[i+1][j-1];
  10. dp[i][j] = aux % val;
  11. } else
  12. if(i + 1 == lungime){
  13. } else {
  14. aux = (dp[i-1][j-1] + (i+1) * dp[i+1][j-1]);
  15. dp[i][j] = aux % val;
  16. }
  17. } else
  18. if(charachets[j] == '_'){
  19. aux = i * dp[i][j-1];
  20. dp[i][j] = aux % val;
  21. }
  22. }
  23. }
  24. return dp[0][lungime - 1];
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement