結果

問題 No.3072 Sum of sqrt(x)
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-09-12 16:16:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,651 bytes
コンパイル時間 3,827 ms
コンパイル使用メモリ 94,072 KB
実行使用メモリ 5,140 KB
最終ジャッジ日時 2023-08-30 15:16:01
合計ジャッジ時間 42,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 4 ms
4,388 KB
testcase_04 AC 3 ms
4,384 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 667 ms
4,384 KB
testcase_08 AC 655 ms
4,384 KB
testcase_09 AC 618 ms
4,384 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }

const long double EPS = 1e-16;

int main() {
  char buf0[110], buf1[110];
  int N;
  for (; ~scanf("%d", &N); ) {
    Int upp = 0;
    long double low = 0.0;
    for (int i = 0; i < N; ++i) {
      Int x;
      scanf("%lld", &x);
      if (x > 0) {
        /*
          sqrt(X[i]) - k
          = (X[i] - k^2) / (sqrt(X[i]) + k)
        */
        const long double y = sqrtl((long double)x);
        const Int k = (Int)y;
        upp += k;
        low += (x - k * k) / (y + k);
        const Int l = (Int)(low + EPS);
        upp += l;
        low -= l;
      }
      const int len0 = sprintf(buf0, "%lld", upp);
      sprintf(buf1, "%.*Lf", 16 - len0, max(low, 0.0L));
      printf("%s%s\n", buf0, buf1 + 1);
    }
  }
  return 0;
}
0