题目链接

https://www.patest.cn/contests/gplt/L2-020

思路

从师父开始 一层一层往下搜

然后 搜到 得道者 就更新答案

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss; const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6; const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7; ll n; double z, r; struct Node
{
int tot;
vector <int> v;
}temp; ld ans = 0.0; vector <Node> d, da; void dfs(int x, int cur)
{
if (d[x].tot == 0)
{
ans += z * pow(r, cur) * d[x].v[0];
return;
}
vector <int>::iterator it;
for (it = d[x].v.begin(); it != d[x].v.end(); it++)
{
dfs((*it), cur + 1);
}
} int main()
{
int num;
scanf("%lld%lf%lf", &n, &z, &r);
r = (100 - r) * 1.0 / 100;
for (int i = 0; i < n; i++)
{
scanf("%d", &temp.tot);
temp.v.clear();
if (temp.tot == 0)
{
scanf("%d", &num);
temp.v.pb(num);
}
for (int j = 0; j < temp.tot; j++)
{
scanf("%d", &num);
temp.v.pb(num);
}
d.pb(temp);
}
dfs(0, 0);
printf("%.0Lf\n", ans - 0.5);
}

最新文章

  1. Ubuntu下基于Saprk安装Zeppelin
  2. .net sharepoint文档库操作
  3. Get&amp;Post登录
  4. 如何让Ue4画面产生振动效果
  5. BizTalk动手实验(四)Schema开发测试
  6. webView.loadUrl 错误:A WebView method was called on thread &#39;JavaBridge&#39;.
  7. 在mac上安装nodejs
  8. CSS对浏览器的兼容性(IE和Firefox)技巧整理
  9. [ZZ] Understanding 3D rendering step by step with 3DMark11 - BeHardware &gt;&gt; Graphics cards
  10. DBA_Oracle Erp R12安装虚拟机镜像IP修正(案例)
  11. IQueryable与IEnumberable的区别
  12. Spark 初级算子
  13. Javascript中关于作用域和闭包和域解释的面试题
  14. 关于&lt;超文本&gt;定义
  15. Docker: repository, image, container
  16. 虚函数表:QT5与VS2015的差异
  17. spring使用注解通过子类注入父类的私有变量
  18. 深入理解Java虚拟机05--虚拟机类加载机制
  19. Mapper动态代理方式
  20. CentOS 7 使用SVN+Apache搭建版本控制服务器

热门文章

  1. 解决官网下载jdk只有5k大小的错误
  2. 单源最短路Dijstra算法
  3. 对象第复制operator=
  4. Linux下ntp时间同步
  5. 转: Syslog协议介绍
  6. [Redis]windows下redis的安装和启动
  7. 【深入JAVA EE】Spring配置文件解析
  8. C 语言学习 3
  9. 浏览器前缀-----[译]Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
  10. js获取和设置属性的方法