fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <complex>
  5.  
  6. using namespace std;
  7.  
  8. const int pp = 29;
  9. typedef complex<double> cdbl;
  10.  
  11. int main() {
  12. clock_t start = clock();
  13. cdbl ff[pp], gg[pp];
  14. for(int ii = 0; ii < pp; ii++) {
  15. ff[ii] = gg[ii] = 1.0;
  16. }
  17.  
  18. for(int it = 0; it < 1000; it++) {
  19. cdbl dual[pp];
  20.  
  21. for(int ii = 0; ii < pp; ii++) {
  22. dual[ii] = 0.0;
  23. }
  24.  
  25. for(int h1 = 0; h1 < pp; h1 ++) {
  26. for(int h2 = 0; h2 < pp; h2 ++) {
  27. cdbl avg_right = 0.0;
  28. for(int xx = 0; xx < pp; xx ++) {
  29. int c00 = xx, c01 = (xx + h1) % pp, c10 = (xx + h2) % pp,
  30. c11 = (xx + h1 + h2) % pp;
  31. avg_right += ff[c00] * conj(ff[c01]) * conj(ff[c10]) * gg[c11];
  32. }
  33. avg_right /= static_cast<cdbl>(pp);
  34.  
  35. for(int xx = 0; xx < pp; xx ++) {
  36. int c01 = (xx + h1) % pp, c10 = (xx + h2) % pp,
  37. c11 = (xx + h1 + h2) % pp;
  38. dual[xx] += conj(ff[c01]) * conj(ff[c10]) * ff[c11] * conj(avg_right);
  39. }
  40. }
  41. }
  42. for(int ii = 0; ii < pp; ii++) {
  43. dual[ii] = conj(dual[ii]) / static_cast<double>(pp*pp);
  44. }
  45.  
  46. for(int ii = 0; ii < pp; ii++) {
  47. gg[ii] = dual[ii];
  48. }
  49.  
  50.  
  51. }
  52. printf("%.15lf\n", gg[0].real());
  53. printf( "%lf\n" , ( double )( clock() - start ) / ( double )CLOCKS_PER_SEC );
  54. return 0;
  55. }
Success #stdin #stdout 0.39s 15240KB
stdin
Standard input is empty
stdout
1.000000000000000
0.394447