Cappuccino90

neues DUDU mit for und double

Oct 11th, 2015
172
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. import java.math.BigInteger;
  2.  
  3. public class DUDU {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         int n = 500;
  8.  
  9.         for (int i = 5; i <= n; i++) {
  10.  
  11.             double[][][][] E = new double[2 * n][2 * n + 3][5][4];
  12.  
  13.             E[0][2][1][0] = 1;
  14.  
  15.             for (int x = 1; x < 2 * i; x++) {
  16.  
  17.                 for (int s = (x + 1) % 2; s < x + 2; s += 2) {
  18.  
  19.                     for (int a = 0; a <= 2; a++) {
  20.  
  21.                         E[x][s + 1][a + 1][0] = E[x - 1][s][a + 1][0] + E[x - 1][s][a + 1][2];
  22.  
  23.                         E[x][s + 1][a + 1][1] = E[x - 1][s + 2][a + 1][0] + E[x - 1][s + 2][a + 1][1]
  24.                                 + E[x - 1][s + 2][a + 1][3];
  25.  
  26.                         E[x][s + 1][a + 1][2] = E[x - 1][s][a][3] + E[x - 1][s][a + 1][1];
  27.  
  28.                         E[x][s + 1][a + 1][3] = E[x - 1][s + 2][a + 1][2];
  29.                     }
  30.  
  31.                 }
  32.  
  33.             }
  34.  
  35.             BigInteger sum = BigInteger.ZERO;
  36.             double sum1=0;
  37.            
  38.            
  39.             for (int x = 0; x < 4; x++) {
  40.                 //System.out.println(E[2 * i - 1][1][3][x]);
  41.                // sum = sum.add(BigInteger.valueOf(E[2 * i - 1][1][3][x]));
  42.                
  43.                 sum1+=E[2 * i - 1][1][3][x];
  44.             }
  45.             System.out.println("n=" + i + ": " + sum1);
  46.  
  47.         }
  48.  
  49.     }
  50.  
  51. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment