Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int MOD = 100;
- vector<pair<int,int>> good = {{3, 40}, {8,50},{23,60}, {43, 70}, {78, 80},{93,90},{100, 100}};
- vector<pair<int,int>> fair = {{10, 40}, {28,50},{68,60}, {88, 70}, {96, 80},{100,90}};
- vector<pair<int,int>> poor = {{44, 40}, {66,50},{82,60}, {94, 70}, {100, 80}};
- vector<pair<int,string>> newsdays_type = {{35, "good"}, {80, "fair"}, {100, "poor"}};
- int get_demand (string news_days_type, int r) {
- if (news_days_type == "good") {
- for (int i = 0; i < (int) good.size(); ++i) {
- if (r <= good[i].first) return good[i].second;
- }
- } else if (news_days_type == "fair") {
- for (int i = 0; i < (int) fair.size(); ++i) {
- if (r <= fair[i].first) return fair[i].second;
- }
- } else {
- for (int i = 0; i < (int) poor.size(); ++i) {
- if (r <= poor[i].first) return poor[i].second;
- }
- }
- }
- string get_news_day (int r) {
- for (int i = 0; i < (int) newsdays_type.size(); ++i) {
- if (r <= newsdays_type[i].first) return newsdays_type[i].second;
- }
- }
- vector<int> rand_news_days, rand_demand, demand;
- vector<double> rev_sales,lost_profit, salvage, daily_profit,newspaper_cost;
- vector<string> news_days;
- int main() {
- int days;
- cin >> days;
- for (int i = 0; i < days; ++i) {
- rand_news_days.push_back(rand() % MOD + 1);
- rand_demand.push_back(rand() % MOD + 1);
- }
- //~ for (int i = 0; i < days; ++i) cout << rand_demand[i] << ' ';
- //~ return 0;
- for (int i = 0; i < days; ++i) {
- string type = get_news_day(rand_news_days[i]);
- news_days.push_back(type);
- }
- for (int i = 0; i < days; ++i) {
- int newspaper_demand = get_demand(news_days[i], rand_demand[i]);
- demand.push_back(newspaper_demand);
- }
- for (int i = 0; i < days; ++i) {
- rev_sales.push_back((double) demand[i] * (50 / 100.0));
- }
- for (int i = 0; i < days; ++i) {
- int left = demand[i] - 70;
- left = max(0, left);
- lost_profit.push_back(0.17 * left);
- }
- for (int i = 0; i < days; ++i) {
- int left_over = 70 - demand[i];
- left_over = max(0, left_over);
- salvage.push_back(left_over * 0.05);
- }
- for (int i = 0; i < days; ++i) {
- newspaper_cost.push_back(70 * 0.33);
- }
- for (int i = 0; i < days; ++i) {
- daily_profit.push_back(rev_sales[i] - newspaper_cost[i] - lost_profit[i] + salvage[i]);
- }
- cout << "Days\tRNNews\tNewsdays\tRNDem\tDem\tRevSal\tLostProf\tSal\tNewsCost\tProf\n";
- for (int i = 0; i < days; ++i) {
- 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';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement