Cod sursa(job #2406379)
| Utilizator | Data | 15 aprilie 2019 18:15:06 | |
|---|---|---|---|
| Problema | Dezastru | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("dezastru.in");
ofstream g("dezastru.out");
vector<double> a;
const double z=0.0000001;
const int x=10000000;
double n,k,s;
int sol;
long long fac(long long);
int main()
{
f>>n>>k;
for(int i=1;i<=n;i++)
f>>a[i];
do
{
s+=(a[1]*a[2])/fac(n);
}
while(next_permutation(a.begin(),a.end()));
sol=(int)s*x;
g<<fixed<<setprecision(6);
g<<s-sol%10*z;
return 0;
}
long long fac(long long n)
{
long long p=1;
for(int i=2;i<=n;i++)
p*=i;
return p;
}
