fork(6) download
  1. /*Utkarsh and Jumps*/
  2. //by Tanmay Chaudhari
  3. #ifdef _MSC_VER
  4. #define _CRT_SECURE_NO_WARNINGS
  5. #endif
  6. //#pragma comment(linker, "/STACK:66777216")
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9.  
  10. #define si(a) scanf("%d",&a)
  11. #define sl(a) scanf("%lld",&a)
  12. #define pi(a) printf("%d\n",a)
  13. #define pl(a) printf("%lld\n",a)
  14.  
  15. typedef long long ll;
  16. typedef vector<int> vi;
  17. typedef pair<int, int> ii;
  18. typedef vector<vi> vvi;
  19. typedef vector<ii> vii;
  20.  
  21. #define SET(a,b) memset(a,b,sizeof(a))
  22. #define forall(i,a,b) for(int i=a; i<b; i++)
  23. #define forrev(i,a,b) for(int i=a; i>=b; i--)
  24. #define forr(it,container) for(auto it=container.begin(); it!=container.end(); it++)
  25. #define w(t) int t;si(t);while(t--)
  26.  
  27. #define TRACE
  28.  
  29. #ifdef TRACE
  30. #define trace1(x) cerr << #x << ": " << x << endl;
  31. #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
  32. #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
  33. #define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
  34. #define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
  35. #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
  36.  
  37. #else
  38.  
  39. #define trace1(x)
  40. #define trace2(x, y)
  41. #define trace3(x, y, z)
  42. #define trace4(a, b, c, d)
  43. #define trace5(a, b, c, d, e)
  44. #define trace6(a, b, c, d, e, f)
  45.  
  46. #endif
  47.  
  48. double dp[1 << 20];
  49. int main()
  50. {
  51. //freopen("input.txt","r",stdin);
  52. //freopen("output.txt","w",stdout);
  53. int n;
  54. double p;
  55. si(n); scanf("%lf", &p);
  56. p /= 100.0;
  57. dp[0] = 1;
  58. for (int i = 1; i <= n; i++)
  59. {
  60. if (i - 2 >= 0)
  61. dp[i] += dp[i - 2] * p;
  62. if (i - 3 >= 0)
  63. dp[i] += dp[i - 3] * (1.0-p);
  64. }
  65. printf("%.6f\n", dp[n]);
  66. return 0;
  67. }
Runtime error #stdin #stdout 0s 11656KB
stdin
Standard input is empty
stdout
Standard output is empty