#include<iostream> #include<vector> #include<cstdio> using namespace std; const int N = 1e5 + 10; vector<int>v[N]; int n ,vis[N]; double z ,r ,sum ,ans; void dfs (double sum ,int u) { if (vis[u]) { ans += (sum * v[u][0]); return ; } for (int i = 0;i < v[u].size(); i++) { dfs (sum * (1 - r / 100) ,v[u][i]); } } int main() { cin >> n >> z >> r; for (int i = 0;i < n; i++) { int k ,x; cin >> k; if (!k) { cin >> x; vis[i] = 1; v[i].push_back(x); } else { while (k--) { cin >> x; v[i].push_back(x); } } } dfs(z ,0); printf("%.0lf" ,ans - 0.5); return 0; }
#include<bits/stdc++.h> using namespace std; struct Node{ string s; //姓名 int x; //种类 double y; //平均标签数 }; bool cmp(Node a,Node b) { if(a.x==b.x)return a.y<b.y; return a.x>b.x; } int main() { int n,m,p; set<int>t[105]; Node r[105]; cin>>n; for(int i=0;i<n;i++) { cin>>r[i].s>>m; for(int j=0;j<m;j++) { cin>>p; t[i].insert(p); } r[i].x=t[i].size(); r[i].y=m*1.0/t[i].size(); } sort(r,r+n,cmp); for(int i=0;i<3;i++) { if(i<n) { if(i==0) cout<<r[i].s; else cout<<" "<<r[i].s; } else cout<<" -"; } return 0; }
标签:Node,int,sum,cin,vis,include,8.11 From: https://www.cnblogs.com/xuxingkai/p/17623877.html