andyli

题解 洛谷 P5082 【成绩】
这道题非常简单(废话),但要注意这题输入数据量大,只能用scanf/快读/ios::sync_with_stdio...
扫描右侧二维码阅读全文
10
2018/12

题解 洛谷 P5082 【成绩】

这道题非常简单(废话),但要注意这题输入数据量大,只能用scanf/快读/ios::sync_with_stdio(false)+cin。

完整代码如下:

#include <cstdio>
const int maxn = 10000005;

int A[maxn], B[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    long long sum = 0;
    for (int i = 0; i < n; i++)
        scanf("%d", A + i), sum += A[i];
    long long sum2 = 0, sum3 = 0;
    for (int i = 0; i < n;i++)
        scanf("%d", B + i), sum2 += B[i], sum3 += A[i] - B[i];
    printf("%.6f\n", double(sum * 3 - sum2 * 2) / sum3);
    return 0;
}

最后要转换成double进行输出。

Last modification:June 25th, 2019 at 11:15 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment