本文共 727 字,大约阅读时间需要 2 分钟。
传送门:
AC代码
#include#include #include #include #include #include using namespace std;struct Node{ Node *parent; int num,level; Node():num(0),level(-1),parent(NULL){};};void init(Node * T){ if(T->level==-1){ if(T->parent==NULL) T->level = 0; else { if(T->parent->level==-1) init(T->parent); T->level = T->parent->level+1; } }}int main(){ int n,m,t; double price,rate; scanf("%d %lf %lf",&n,&price,&rate); vector tree; for (int i=0; i num=-1; for (int j=0; j parent = tree[i]; } }else scanf("%d",&tree[i]->num); } for (int i=0; i num!=-1){ int x = tree[i]->level; totalPrice += price * pow((1+0.01*rate),x) * tree[i]->num; } } printf("%.1lf\n",totalPrice); return 0;}
转载地址:http://aqhji.baihongyu.com/