結果

問題 No.8072 Sum of sqrt(x)
ユーザー chocorusk
提出日時 2020-09-13 00:47:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,183 ms / 2,000 ms
コード長 1,558 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 125,024 KB
最終ジャッジ日時 2025-01-14 14:12:00
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%lld", &x);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int n;
    scanf("%d", &n);
    long double ans=0, r=0;
    for(int i=0; i<n; i++){
        ll x;
        scanf("%lld", &x);
        long double a=sqrt((long double)x);
        long double t=ans+a+r;
        r=a+r-(t-ans);
        ans=t;
        if(ans<1e1) printf("%.16Lf\n", ans);
        else if(ans<1e2) printf("%.15Lf\n", ans);
        else if(ans<1e3) printf("%.14Lf\n", ans);
        else if(ans<1e4) printf("%.13Lf\n", ans);
        else if(ans<1e5) printf("%.12Lf\n", ans);
        else if(ans<1e6) printf("%.11Lf\n", ans);
        else if(ans<1e7) printf("%.10Lf\n", ans);
        else if(ans<1e8) printf("%.9Lf\n", ans);
        else if(ans<1e9) printf("%.8Lf\n", ans);
        else if(ans<1e10) printf("%.7Lf\n", ans);
        else if(ans<1e11) printf("%.6Lf\n", ans);
        else if(ans<1e12) printf("%.5Lf\n", ans);
        else if(ans<1e13) printf("%.4Lf\n", ans);
        else if(ans<1e14) printf("%.3Lf\n", ans);
        else printf("%.2Lf\n", ans);
    }
    return 0;
}
0