【无标题】求问pta的1-9 功夫传人,为什么第二个样例是错的

#include<cstdio>
#include<stdlib.h>
#pragma warning(disable:4996)
using namespace std;
#define MAX 100005
typedef struct node
{
    int tea;
    int stucount;
    int* stu;
    int be;
    double z;
}Node;
double R = 0.0;
Node* s;
void kongfu(Node* t)
{
    for (int i = 0; i < t->stucount; i++)
    {
        if (s[t->stu[i]].stucount == 0)
        {
            s[t->stu[i]].z = t->z * R * s[t->stu[i]].be;
            continue;
        }
        s[t->stu[i]].z = t->z * R;
        kongfu(&s[t->stu[i]]);
    }
}
int main()
{
    s = (Node*)malloc(sizeof(Node) * MAX);
    int N;
    double Z, r;
    scanf("%d %lf %lf", &N, &Z, &r);
    R = (100 - r) / 100.0;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &s[i].stucount);
        if (s[i].stucount == 0)
        {
            scanf("%d", &s[i].be);
            continue;
        }
        s[i].stu = (int*)malloc(s[i].stucount * sizeof(int));
        for (int j = 0; j < s[i].stucount; j++)
        {
            scanf("%d", &s[i].stu[j]);
        }
    }
    s[0].z = Z;
    kongfu(&s[0]);
    double count = 0.0;
    for (int i = 0; i < N; i++)
    {
        if (s[i].stucount == 0)
        {
            count += s[i].z;
        }
    }
    long long count1 = count;
    printf("%lld", count1);
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值