2 条题解
-
0
map+前缀和(其实set更好)
#include<bits/stdc++.h> using namespace std; using ll=long long; map<ll,int>mp; int main() { int n; cin>>n; ll ay; for(int i=1;i<=n;i++){ cin>>ay; mp[ay]++; } //终态:删完 //过程:对不同元素进行等概率删除 int nu=mp.size(); vector<double>pre(n+1,0); vector<double>a(n+1,0); double j=1.0; for(int i=1;i<=n;i++){ a[i]=1/j; pre[i]=pre[i-1]+a[i]; j++; } cout<<fixed<<setprecision(8)<<pre[nu]<<endl; }
信息
- ID
- 130
- 时间
- 3000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 36
- 已通过
- 5
- 上传者