SHARE
TWEET

Untitled

a guest Jan 26th, 2017 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = 2018;
  2. m = 104;
  3. mod = 2^89 - 1;
  4. dp = Table[0, {i, n}, {j, m}];
  5. For[i = 2, i <= n, ++i, Print[i];
  6.     cur = 2 * PowerMod[3, i - 2, mod];
  7.     For[j = 1, j <= m, ++j,
  8.    dp[[i]][[j]] = dp[[i - 1]][[j]] + PowerMod[cur, j - 1, mod]];
  9.     For[p = 0, p < m, ++p,
  10.         For[a = 0, a <= p, ++a, b = p - a;
  11.                 factmult = Mod[(p!/a!/b!), mod];
  12.                 A = PowerMod[cur, a, mod];
  13.                 B = dp[[i - 1]][[b + 1]];
  14.                 dp[[i]][[p + 1]] += Mod[factmult * A*B , mod];
  15.                 dp[[i]][[p + 1]] = Mod[dp[[i]][[p + 1]], mod];
  16.     ]]];
  17. Print[dp[[n]][[m]]];
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top