sdnu oj 1322 Definite Integral

显然这是个求面积的题,坑点: 变化路线是函数 , 所以要用积分求
因为是求比例, 只算第一象限就可以
在这里插入图片描述
但是玄学 WA 了, 所以仅供参考

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;

typedef long long ll;
const int N = 10000006;

int main()
{
    int t;
    double a, b, s;
    scanf("%d", &t);
    while(t--)
    {
        scanf("%lf%lf%lf", &a, &b, &s);
        if(a*b <= s)
        {
            double ans = 0;
            printf("%.6lf%%\n", ans);  //%是转义符。例如/,两个//代表一个/,同理所以两个%% 代表一个%
        }
        else if(s == 0)
        {
            double ans = 100;
            printf("%.6lf%%\n", ans);
        }
        else
        {
            double ans;
            double m = a*b;
            ans = (m - s - s*log(m/s)) / m;
            ans *= 100;
            printf("%.6lf%%\n", ans);
        }
    }
    return 0;
}

发布了40 篇原创文章 · 获赞 4 · 访问量 1130

猜你喜欢

转载自blog.csdn.net/xiongshuxian2019/article/details/104428455