牛オフの練習試合46 Aチワワ教えるオリンパス・ライト・ジオメトリ(単純な数学)

リンク:https://ac.nowcoder.com/acm/contest/894/A
出典:牛オフネットワーク

チワワは、オリンパスは、幾何学的記述教える
時間制限:C / C ++ 1秒を、他の言語2秒
スペースの制約:C / C ++ 524288K、他の言語1048576K
64ビットIOフォーマット:%LLD
タイトル説明
オリンパスの形状が悪いですが、オリンパスは認識されません、その中国と中国オリンパスは、トピックを投げます。図:

大半円と二つの小さな半円形の半径に等しい半径知ら。エリアの赤い部分与えられた場合は、大円の最小半径はどのくらいですか?とにかく、今お答えください、これまでと同じようににぎやかではありません。
入力説明:
赤い部分の面積で表される正の整数Sを入力します。
1 <= S <= 1E9の
出力説明:
大円の分数半径を出力は、最小、小数点以下3桁を表し
、実施例1
の入力
コピー
2
出力
コピー
1.596
実施例2
入力
コピー
3
出力
コピー
1.954を

アイデア:

問題の書き込み半分の解がある見たい数式を指示、何この問題の半分を理解していませんでしたか?

もちろん、我々は偉大円の最小半径をしたい、我々は半円であり、二つの小さな半円の直径の半径ため、できる限り赤い部分を聞かせなければならない大きな半円、最も赤い部分です。

次いで、R *、R = 4 * S /π

詳細コードを参照してください。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define pi acos(-1)
#define gg(x) getInt(&x)
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    
    gbtb;
    double s;
    cin>>s;
    s*=4.00;
    double r=s/pi;
    cout<<fixed<<setprecision(3)<<sqrt(r)<<endl;
    
    
    
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



おすすめ

転載: www.cnblogs.com/qieqiemin/p/11300756.html