分组样例代码

#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;

unsigned int JSHash(const char* str)
{
    unsigned int hash = 1315423911;
    while (*str)
    {
        hash ^= ((hash << 5) + (*str++) + (hash >> 2));
    }
    return (hash & 0x7FFFFFFF);
}

int choosePolise(unsigned int custId)
{
    double cp = (JSHash(to_string(unsigned (custId)).c_str()) % 200 + 1) / 200.0;
    //cout << cp << endl;
    int number = 0;
    double policies_ratio[] = { 0.2,0.2,0.2,0.2,0.2 };
    //double policies_ratio[] = { 0.33,0.33,0.34 };
    //double policies_ratio[] = { 0.25,0.25,0.25,0.25 };
    //double policies_ratio[] = { 0.5,0.5 };
    //double policies_ratio[] = { 0.15,0.15,0.15,0.25,0.15,0.15 };

    int policy_num = 5 ;
    while (number < policy_num && (policies_ratio[number] - cp) < 0.0001)
    {
        cp = cp - policies_ratio[number];
        if (number == policy_num - 1)
            break;
        number++;
    }
    cout << to_string(custId) + " ### " + to_string(cp) + " ###  " + to_string(number) << endl;
    return number;
}

int main() {
    int custId;
    //int custIdList[13] = {1800910528,1710766244,1234590337,1553283882,1165445462,1557052348,1557052349,1524244103,1520001269,1511291164,1802090458,1801999148,1803350941 };
    for ( int i = 1808781239; i <= 1808781248; i++)
    {
        custId = i;
        cout << custId << endl;
        int police = choosePolise(custId);
    }
    return 0;

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值