結果
| 問題 |
No.1157 Many Quotients easy
|
| ユーザー |
|
| 提出日時 | 2022-03-13 13:31:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,160 bytes |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 80,708 KB |
| 最終ジャッジ日時 | 2025-01-28 09:17:42 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#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;
}