fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. int main() {
  6. std::vector<int> scv = {
  7. -3, 13, 6, -29, -31, 43, 46, 8, 7, 21, 12, 6, 31, 38, 2, 31,
  8. 12, -8, 23, 14, -22, 37, 24, 19, -2, 24, 17, 31, -6, 2, 4, 11,
  9. -13, 41, 17, 4, 15, -9, -32, 33, 23, -6, 18, 32, 9, -6, 23, 9,
  10. -15, 20, 3, 19, -16, 11, 8
  11. };
  12.  
  13. std::vector<int> vti = {
  14. -2, 11, 12, -25, -36, 30, 21, -11, -1, 5, 16, -11, 19, 19, 1, 28,
  15. 15, -2, 12, 24, -10, 29, 6, 8, -1, 34, 19, 30, 24, 19, -13, -9,
  16. -25, 30, 8, 2, 12, 1, -37, 26, 16, -2, 14, 31, 12, 0, 11, 19,
  17. -7, 28, 19, 18, -24, 22, 20
  18. };
  19.  
  20. int t = vti.size();
  21. vector<double> tmp(t,1.0);
  22. vector<vector<double>> telltale(t, tmp);
  23.  
  24. for(int l=0;l< t;l++)
  25. {
  26. for(int r=l; r<t;r++)
  27. {
  28. int cnt = r-l+1;
  29. double d= 1.0;
  30. for(int k=0; k<cnt;k++)
  31. {
  32. double scv_r = (100.0 +scv[l+k])/100,
  33. vti_r = (100.0 +vti[l+k])/100;
  34. d = (d*scv_r)/vti_r;
  35. }
  36. telltale[l][r]= d;
  37. }
  38. }
  39. vector<vector<double>> distribution_telltale_rolling_period(t+1);
  40. for(int l=0;l<t;l++)
  41. {
  42. for(int r=l;r<t;r++)
  43. {
  44. distribution_telltale_rolling_period[r-l+1].push_back(telltale[l][r]);
  45. }
  46. }
  47.  
  48. double prev =1.0;
  49. for(int i=0;i< t;i++)
  50. {
  51. double perc = ((telltale[0][i]- prev)/prev)*100;
  52. prev = telltale[0][i];
  53. cout<< perc<<endl;
  54. }
  55.  
  56. // for(int i=1;i< (t+1);i++)
  57. // {
  58. // sort(distribution_telltale_rolling_period[i].begin(),
  59. // distribution_telltale_rolling_period[i].end());
  60. // //cout<<"\n"<<i;
  61. // for(int j=0; j< distribution_telltale_rolling_period[i].size();j++)
  62. // {
  63. // cout<<"(";
  64. // cout<<i<<","<<distribution_telltale_rolling_period[i][j]<<"),";
  65. // }
  66. // }
  67. return 0;
  68. }
  69.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
-1.02041
1.8018
-5.35714
-5.33333
7.8125
10
20.6612
21.3483
8.08081
15.2381
-3.44828
19.1011
10.084
15.9664
0.990099
2.34375
-2.6087
-6.12245
9.82143
-8.06452
-13.3333
6.20155
16.9811
10.1852
-1.0101
-7.46269
-1.68067
0.769231
-24.1935
-14.2857
19.5402
21.978
16
8.46154
8.33333
1.96078
2.67857
-9.90099
7.93651
5.55556
6.03448
-4.08163
3.50877
0.763359
-2.67857
-6
10.8108
-8.40336
-8.60215
-6.25
-13.4454
0.847458
10.5263
-9.01639
-10