結果

問題 No.2352 Sharpened Knife in Fall
ユーザー HIcoderHIcoder
提出日時 2023-07-05 14:42:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 3,000 ms
コード長 1,710 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 102,588 KB
実行使用メモリ 4,428 KB
最終ジャッジ日時 2023-09-26 14:40:00
合計ジャッジ時間 10,812 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 167 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 244 ms
4,380 KB
testcase_07 AC 124 ms
4,380 KB
testcase_08 AC 243 ms
4,380 KB
testcase_09 AC 245 ms
4,384 KB
testcase_10 AC 245 ms
4,380 KB
testcase_11 AC 242 ms
4,428 KB
testcase_12 AC 244 ms
4,380 KB
testcase_13 AC 243 ms
4,384 KB
testcase_14 AC 114 ms
4,384 KB
testcase_15 AC 227 ms
4,384 KB
testcase_16 AC 13 ms
4,384 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 89 ms
4,384 KB
testcase_19 AC 193 ms
4,384 KB
testcase_20 AC 76 ms
4,380 KB
testcase_21 AC 73 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);

double area(double r,double y){
    double theta=acos(y/r);

    return r*r*theta - y*sqrt(r*r-y*y);

}

int main(){
    int R,K;
    cin>>R>>K;

    int halfK=K/2;

    vector<double> ans;
    
    double upperb=R;
    for(int k=1;k<=halfK;k++){
        //double ub=upperb;
        double ub=R;
        double lb=0;
        
        double Sk=1.0*PI*R*R*k/(K+1);

        for(int x=0;x<100;x++){
            double mid=(ub+lb)/2;

            //cout<<"k="<<k<<endl;
            //cout<<"ub="<<ub<<endl;
            //cout<<"lb="<<lb<<endl;


            if(area(R,mid)<=Sk){
                ub=mid;
            }else{
                lb=mid;
            }

        }
        //cout<<"ub="<<ub<<endl;

        ans.push_back(ub);

        //upperb=ub;
    }
    /*
    sort(ans.begin(),ans.end());//絶対値が小さい順
    reverse(ans.begin(),ans.end());//絶対値が大きい
    */
    int n=ans.size();

    if(K%2==1){

        for(int k=0;k<n;k++){
            printf("%.13f\n",-ans[k]);
        }
        
        //printf("%.13f\n",0.0);
        cout<<0<<endl;
        
        for(int k=n-1;k>=0;k--){
            printf("%.13f\n",ans[k]);
        }

        
        
    }else{
        
        for(int k=0;k<n;k++){
            printf("%.13f\n",-ans[k]);
        }


        for(int k=n-1;k>=0;k--){
            printf("%.13f\n",ans[k]);
        }
        
    }


}
0