zoukankan      html  css  js  c++  java
  • 帝国的困境:80-20法则

    #include <vector>
    #include <stdlib.h> 
    #include <time.h>
    
    using namespace std;
    
    class Person
    {
    public:
        bool consume_money() {
            if(money >= 10) {
                money -= 10;
                return true;
            } else {
                return false;
            }
        }
        void earn_money() {
            money += 10;
        }
        void show_money() {
            printf("%d	", money);
        }
    
    private:
        uint32_t money = 100;
    };
    
    int main()
    {
        vector<Person> society(10);
        srand(time(NULL));
        auto consumption_cycle = [&society] {
            for(auto &p : society) {
                bool re = p.consume_money();
                if (!re)continue;
                uint8_t producer_id = (uint8_t)(rand() % 10);
                society[producer_id].earn_money();
            }            
        };
    
        for (int i = 0; i < 100000000; i++) {
            consumption_cycle(); //100000000 cycles later
        }
    
        for (auto &p : society) {
            p.show_money();
        }
        getchar();
        return 0;
    }

    结果:

    earn_money的人是用时间为seed的纯随机分配,结果仍然是20%的人掌握了71%的财富

    真实的社会中,有能力先赚到钱的人会加大投资,掌握更多的资源,在earn_money中有更高的优先级。

    中国5000年的文明史中,一个全新王朝数百年后基本上都会崩溃,贫富差距过大是底层人民革命的根本原因。

    忧国忧民的人,大概都是看到了这个问题,又想不出办法来解决吧,你有什么好的算法可以解决这个问题吗?

  • 相关阅读:
    Codeforces Round #562题解
    Codeforces Round #561题解
    CF1107E Vasya and Binary String(区间dp)
    NC110113 Summer Earnings(bitset)
    NC112798 XOR-pyramid(dp)
    NC23051 华华和月月种树(离线+树状数组)
    py.path模块
    stat模块
    pwd模块
    PrettyTable模块
  • 原文地址:https://www.cnblogs.com/awiki/p/13781066.html
Copyright © 2011-2022 走看看