1 条题解

  • 0
    @ 2025-9-10 9:00:40

    C++ :

    #include <stdlib.h>
    
    #include <cstdio>
    #include <string>
    using namespace std;
    
    bool done;
    
    double doit() {
      char ch;
      do {ch = getchar();} while (isspace(ch));
      if (ch == ')') exit(0);
      if (ch == '(') {
        double p;
        scanf("%lf", &p);
        return doit() + (p-(1-p)) * doit();
      } else {
        string s;
        while (!isspace(ch)) {s += ch; ch = getchar();}
        return atoi(s.c_str());
      }
    }
    
    main() {
      for(;;) {printf("%.2lf\n", doit()); fflush(stdout);}
    }
    
    
    • 1

    信息

    ID
    3643
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者