这数据有问题啊:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
int main() {
std::vector<double> vp = {0.3047, 0.2874, 0.1351, 0.0481, 0.0481,
0.0458, 0.0309, 0.0263, 0.0183, 0.0160};
int total_count = 10;
while (true) {
if (std::all_of(vp.begin(), vp.end(), [&](double pct) {
int count = std::round(pct * total_count);
return std::abs(1.0 * count / total_count - pct) <= 0.00005;
})) {
break;
}
total_count++;
}
std::cout << "Total count is " << total_count << std::endl;
for (const auto p : vp) {
std::cout << "Percent " << p*100 << "\t has count " << round(p * total_count)
<< std::endl;
}
return 0;
}
Total count is 5202
Percent 30.47 has count 1585
Percent 28.74 has count 1495
Percent 13.51 has count 703
Percent 4.81 has count 250
Percent 4.81 has count 250
Percent 4.58 has count 238
Percent 3.09 has count 161
Percent 2.63 has count 137
Percent 1.83 has count 95
Percent 1.6 has count 83
【 在 AD007 的大作中提到: 】
: 挪威人不识货,居然不搞平行进口的梦想汽车和问界![upload=1][/upload]
--
FROM 222.129.51.*