結果

問題 No.1162 Many Quotients hard
ユーザー masutech16masutech16
提出日時 2022-03-13 13:30:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,160 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 00:06:13
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "sqrt.test.cpp"
#define PROBLEM "https://yukicoder.me/problems/no/1162"

#line 1 "/workspaces/Aice/Src/Integer/Util.hpp"



#line 1 "/workspaces/Aice/Src/Primitive/TypeDef.h"



#include <cstdint>

using s32 = int_fast32_t;
using s64 = int_fast64_t;

using u32 = uint_fast32_t;
using u64 = uint_fast64_t;

using f32 = float;
using f64 = double;
using f128 = long double;


#line 5 "/workspaces/Aice/Src/Integer/Util.hpp"

#include <cmath>
#include <cassert>

namespace aice {
namespace integer {

class Util {
public:

  /**
   * sqrt(target)以下の最大の整数を計算します
   * @param target 平方数を計算したい値。0以上である必要があります
   */
  template<class T>
  static T sqrt_floor(T target) {
    assert(target >= 0);
    T cand = std::sqrt(target);
    while (cand * cand > target) cand--;
    while ((cand + 1) * (cand + 1) <= target) cand++;
    return cand;
  }
};

}
}

#line 4 "sqrt.test.cpp"

#include <iostream>

int main() {
  s64 X;
  std::cin >> X;

  s64 sqrt_X = aice::integer::Util::sqrt_floor(X);

  s64 ans = sqrt_X * 2LL;
  if (X / sqrt_X == sqrt_X) ans--;

  std::cout << ans << std::endl;
}
0