Advertisement
newb_ie

Untitled

Dec 4th, 2021
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MOD = 100;
  5.  
  6. vector<pair<int,int>> good = {{3, 40}, {8,50},{23,60}, {43, 70}, {78, 80},{93,90},{100, 100}};
  7. vector<pair<int,int>> fair = {{10, 40}, {28,50},{68,60}, {88, 70}, {96, 80},{100,90}};
  8. vector<pair<int,int>> poor = {{44, 40}, {66,50},{82,60}, {94, 70}, {100, 80}};
  9. vector<pair<int,string>> newsdays_type = {{35, "good"}, {80, "fair"}, {100, "poor"}};
  10.  
  11. int get_demand (string news_days_type, int r) {
  12. if (news_days_type == "good") {
  13. for (int i = 0; i < (int) good.size(); ++i) {
  14. if (r <= good[i].first) return good[i].second;
  15. }
  16. } else if (news_days_type == "fair") {
  17. for (int i = 0; i < (int) fair.size(); ++i) {
  18. if (r <= fair[i].first) return fair[i].second;
  19. }
  20. } else {
  21. for (int i = 0; i < (int) poor.size(); ++i) {
  22. if (r <= poor[i].first) return poor[i].second;
  23. }
  24. }
  25. }
  26.  
  27. string get_news_day (int r) {
  28. for (int i = 0; i < (int) newsdays_type.size(); ++i) {
  29. if (r <= newsdays_type[i].first) return newsdays_type[i].second;
  30. }
  31. }
  32.  
  33. vector<int> rand_news_days, rand_demand, demand;
  34. vector<double> rev_sales,lost_profit, salvage, daily_profit,newspaper_cost;
  35. vector<string> news_days;
  36.  
  37. int main() {
  38. int days;
  39. cin >> days;
  40. for (int i = 0; i < days; ++i) {
  41. rand_news_days.push_back(rand() % MOD + 1);
  42. rand_demand.push_back(rand() % MOD + 1);
  43. }
  44. //~ for (int i = 0; i < days; ++i) cout << rand_demand[i] << ' ';
  45. //~ return 0;
  46. for (int i = 0; i < days; ++i) {
  47. string type = get_news_day(rand_news_days[i]);
  48. news_days.push_back(type);
  49. }
  50. for (int i = 0; i < days; ++i) {
  51. int newspaper_demand = get_demand(news_days[i], rand_demand[i]);
  52. demand.push_back(newspaper_demand);
  53. }
  54. for (int i = 0; i < days; ++i) {
  55. rev_sales.push_back((double) demand[i] * (50 / 100.0));
  56. }
  57. for (int i = 0; i < days; ++i) {
  58. int left = demand[i] - 70;
  59. left = max(0, left);
  60. lost_profit.push_back(0.17 * left);
  61. }
  62. for (int i = 0; i < days; ++i) {
  63. int left_over = 70 - demand[i];
  64. left_over = max(0, left_over);
  65. salvage.push_back(left_over * 0.05);
  66. }
  67. for (int i = 0; i < days; ++i) {
  68. newspaper_cost.push_back(70 * 0.33);
  69. }
  70. for (int i = 0; i < days; ++i) {
  71. daily_profit.push_back(rev_sales[i] - newspaper_cost[i] - lost_profit[i] + salvage[i]);
  72. }
  73. cout << "Days\tRNNews\tNewsdays\tRNDem\tDem\tRevSal\tLostProf\tSal\tNewsCost\tProf\n";
  74. for (int i = 0; i < days; ++i) {
  75. cout << i + 1 << '\t' << rand_news_days[i] << '\t' << news_days[i] << "\t " << rand_demand[i] << "\t" << demand[i] << '\t' << rev_sales[i] << "\t " << lost_profit[i] << "\t " << salvage[i] << '\t' << newspaper_cost[i] << "\t " << daily_profit[i] << '\n';
  76. }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement