fork download
  1. /*
  2. */
  3.  
  4. //#pragma comment(linker, "/STACK:16777216")
  5. #define _CRT_SECURE_NO_WARNINGS
  6.  
  7. #include <fstream>
  8. #include <iostream>
  9. #include <string>
  10. #include <complex>
  11. #include <math.h>
  12. #include <set>
  13. #include <vector>
  14. #include <map>
  15. #include <queue>
  16. #include <stdio.h>
  17. #include <stack>
  18. #include <algorithm>
  19. #include <list>
  20. #include <ctime>
  21. #include <memory.h>
  22. #include <assert.h>
  23.  
  24. #define y0 sdkfaslhagaklsldk
  25. #define y1 aasdfasdfasdf
  26. #define yn askfhwqriuperikldjk
  27. #define j1 assdgsdgasghsf
  28. #define tm sdfjahlfasfh
  29. #define lr asgasgash
  30. #define norm asdfasdgasdgsd
  31.  
  32. #define eps 1e-9
  33. #define M_PI 3.141592653589793
  34. #define bs 1000000007
  35. #define bsize 350
  36.  
  37. using namespace std;
  38.  
  39. const int INF = 1e9;
  40. const int N = 200000;
  41.  
  42. int res;
  43.  
  44. double dp[105000][180];
  45.  
  46. int main(){
  47. //freopen("fabro.in","r",stdin);
  48. //freopen("fabro.out","w",stdout);
  49. //freopen("F:/in.txt", "r", stdin);
  50. //freopen("F:/output.txt", "w", stdout);
  51. ios_base::sync_with_stdio(0);
  52. //cin.tie(0);
  53.  
  54. for (int i = 2; i < 20; i++)
  55. {
  56. if (i % 2 == 0)
  57. res += 18;
  58. else
  59. res += 1;
  60. }
  61. cout << res << endl;
  62.  
  63. int STEPS = 100000;
  64.  
  65. dp[0][0] = 1.0;
  66. for (int i = 0; i < STEPS; i++)
  67. {
  68. for (int j = 0; j < res-1; j++)
  69. {
  70. if (dp[i][j] < 1e-50)
  71. continue;
  72. if (j>0)
  73. dp[i + 1][j - 1] += dp[i][j] / 4;
  74. else
  75. dp[i + 1][j] += dp[i][j] / 4;
  76.  
  77. dp[i + 1][j + 1] += dp[i][j] / 4;
  78.  
  79. dp[i + 1][j] += dp[i][j] / 2;
  80. }
  81. }
  82.  
  83. double res = 0;
  84. for (int i = 0; i < 170; i++)
  85. res += dp[STEPS][i];
  86. cout.precision(12);
  87. cout << fixed << res << endl;
  88.  
  89. cin.get(); cin.get();
  90. return 0;
  91. }
Success #stdin #stdout 0.39s 151104KB
stdin
Standard input is empty
stdout
171
0.152530538849