博客
关于我
2018蓝桥杯C++A组——付账问题
阅读量:111 次
发布时间:2019-02-26

本文共 1242 字,大约阅读时间需要 4 分钟。

????

????????????????????????????????????????? n ????????? S???????????????????????????????

??

?????????

  • ??????????n ? S????????????????
  • ??????? n ?????????????

??

?????????????????????

????

5 2333666 666 666 666 666 666

????

0.0000

????

???????????????????????????????????????????????????????????????????

[ s = \sqrt{\frac{1}{n} \sum_{i=1}^{n} \left(b_i - \frac{1}{n} \sum_{i=1}^{n} b_i \right)^2} ]

???( s ) ?????( b_i ) ?????????( n ) ?????????

???????????????????????????????????????????????????????????????

  • ?????????????? ( \mu = \frac{S}{n} )?
  • ???????????????
  • ?????
    • ??????????????????????
    • ???????????????????????????????????????? cur_avg??? cur_avg ??????????
  • ???????????????????????????????????

    C++??

    #include 
    using namespace std;typedef long long LL;int n;LL S;double ans = 0.0;double avg = 1.0 * S / n;LL *a = new LL[n];void work() { scanf("%d %lld", &n, &S); ans = 0.0; avg = 1.0 * S / n; LL *a = new LL[n]; for (int i = 0; i < n; ++i) { scanf("%lld", &a[i]); } // ????? double sum = 0.0; for (int i = 0; i < n; ++i) { double diff = a[i] - avg; sum += diff * diff; } ans = sqrt(sum / n); printf("%.4f", ans);}

    ??

    ????????????????

    0.0000

    ???????????????????? 0.0000?

    转载地址:http://swqu.baihongyu.com/

    你可能感兴趣的文章
    Python:如果DataFrames之间的其他值匹配,则对DataFrame中的值求和
    查看>>
    Python:字典思维
    查看>>
    Python:将 HEX 字符串转换为字节
    查看>>
    Python:将列表与范围列表合并
    查看>>
    Python:将列表列表初始化为一定大小,
    查看>>
    Python:带有生成器的给定集合的幂集
    查看>>
    Python:按字符的位置拆分字符串
    查看>>
    Python:替换嵌套字典中的值
    查看>>
    Python:爬取数据出现response.status_code为403解决方法
    查看>>
    Python:爬取数据出现response.status_code为418解决方法
    查看>>
    Python:生成“元组集“;来自“元组列表“;不考虑顺序
    查看>>
    Python:生成具有趋势的随机时间序列数据(例如周期性、指数衰减等)
    查看>>
    Python:用渐进式数字重命名列表中的重复项而不对列表进行排序
    查看>>
    Python:矩形参数无效
    查看>>
    Python:语法进阶
    查看>>
    Python:调用复制函数时调用 Python 对象时超出了最大递归深度
    查看>>
    Python:这两个 import 语句有什么区别?
    查看>>
    Python:通过串口从 Velleman k8090 读取数据
    查看>>
    python:遍历具有列表值的字典
    查看>>
    Python:降低精度 pandas 时间戳数据帧
    查看>>