fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define M1 1000000007
  5. #define M2 998244353
  6. #define ll long long int
  7. #define pll pair<ll,ll>
  8. #define mll map<ll,ll>
  9. #define F first
  10. #define S second
  11. #define PB push_back
  12. #define mp make_pair
  13. #define lb lower_bound
  14. #define ub upper_bound
  15. #define V(a) vector<a>
  16. #define endl '\n'
  17. #define test(t) while(t--)
  18. #define PI acos(-1.0)
  19. #define rep(i,a,b) for(ll i=a;i<b;i++)
  20. #define repp(i,b,a) for(ll i=b-1;i>=a;i--)
  21. #define clr(ar, val) memset(ar, val, sizeof(ar))
  22. #define setbits(x) __builtin_popcountll(x)
  23. #define zrobits(x) __builtin_ctzll(x)
  24. #define ps(y) fixed << setprecision(y)
  25. #define all(x) begin(x),end(x)
  26. #define allr(x) rbegin(x),rend(x)
  27. const int inf= 0x3f3f3f3f;
  28. const ll INF= 0x3f3f3f3f3f3f3f3f;
  29. const int dx[4]= { 0, -1, 0, 1 };
  30. const int dy[4]= { -1, 0, 1, 0 };
  31.  
  32.  
  33.  
  34. class EmptyTheBox{
  35. public:
  36. double Calculate(long long int subset){
  37. double t = 1,sum=0;
  38. while(subset > 0){
  39. if (subset&1) sum += t;
  40. subset >>=1;
  41. t++;
  42. }
  43. return sum;
  44. }
  45.  
  46. double minExpectedPenalty(int D, int T){
  47.  
  48. double* rollprob = new double[2*D+1]();
  49. for(int i = 1; i<=D;++i){
  50. for (int j = 1; j<=D;++j){
  51. rollprob[i+j] += 1./(D*D);
  52. }
  53. }
  54. int excess = 0;
  55. while(T > 2*D) excess+=T,T--;
  56. T = min(2*D,T);
  57. double* dp = new double[1<<T]();
  58. for(long long int subset = 0; subset<(1<<T);++subset){
  59. for (int roll = 2; roll <= 2*D; ++roll){
  60. double X = Calculate(subset);
  61. for(long long int reduceset = 1;reduceset < (1<<T);++reduceset){
  62. if (((subset&reduceset) == reduceset) && (Calculate(reduceset) == roll)){
  63. X = min(X,dp[subset^reduceset]);
  64. }
  65. }
  66. dp[subset] += rollprob[roll]*X;
  67. }
  68. }
  69. return (dp[(1<<T)-1] + excess);
  70. }
  71. };
  72.  
  73. // int main(){
  74. // int d,t;
  75. // cin >> d >> t;
  76. // EmptyTheBox empbx;
  77. // cout << empbx.minExpectedPenalty(d,t) << endl;
  78. // }
  79.  
  80.  
  81.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty