# 3136. 指数比例

$$r(A_i) = \frac{e^{A_i}}{\sum^n_{j=1}e^{A_j}},$$

$$r(A_i) > \beta$$

$$A_i > \log (\alpha\beta)$$

（其实我就是练练写公式，哈哈）

#include <iostream>
#include <cmath>
#include <numeric>
#include <cstdint>
#include <algorithm>
using namespace std;

int main() {
uint32_t t;
cin >> t;
for (uint32_t query = 0; query < t; ++query) {
printf("case #%u:\n", query);
uint32_t n;
cin >> n;
double nums[50];
for (uint32_t i = 0; i < n; ++i) {
cin >> nums[i];
}
sort(nums, nums + n);
auto const passing_line = 0.5 / n;
auto const overall =
accumulate(nums, nums + n, 0.0, [](double accum, double num) { return accum + exp(num); });
auto const threshold = log(overall * passing_line);
auto r_ed = upper_bound(nums, nums + n, threshold);
for (auto i = nums + n - 1; i >= r_ed; --i) {
printf("%.2lf\n", *i);
}
}
}


### include

using namespace std;
int T;
vector V;
vector V2;

int cmp(double aa,double bb)
{
return aa-bb>0;
}
void solve()
{
int n;
cin>>n;
V.clear();

double sum=0;
for(int i=1;i<=n;i++)
{
double xx;
cin>>xx;
sum+=exp(xx);
V.push_back(xx);
}

V2.clear();
for(int i=0;i0) V2.push_back(V[i]);

sort(V2.begin(),V2.end(),cmp);
for(int i=0;i<V2.size();i++) printf(“%.2f\n”,V2[i]);
return;
}

int main()
{
scanf(“%d”,&T);
for(int step=0;step<T;step++)
{
printf(“case #%d:\n”,step);
solve();
}
return 0;
}