1 条题解

  • 0
    @ 2024-12-24 10:06:07

    C :

    #include<stdio.h>
    int main()
    {
    	double a1,b1;
    	double a,b;
    	while(scanf("%lf%lf",&a1,&b1)!=EOF)
    	{
    		a=(a1*a1+b1)/(2*a1);
    		b=a1-a;
    		printf("%.2lf %.2lf\n",a,b);
    	}
    	return 0;
    }
    
    
    

    C++ :

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstdlib>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <queue>
    using namespace std;
    #define out(v) cerr << #v << ": " << (v) << endl
    #define SZ(v) ((int)(v).size())
    const int maxint = -1u>>1;
    template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
    template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}
    
    int main() {
        //freopen("Eming.out", "w", stdout);
        double A, B, C;
        while(scanf("%lf%lf", &A, &B) == 2) {
            C = B / A;
            printf("%.2lf %.2lf\n", (A + C) * 0.5, (A - C) * 0.5);
        }
        return 0;
    }
    
    
    • 1

    信息

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