結果

問題 No.2177 Recurring ab
ユーザー hari64hari64
提出日時 2023-01-06 21:47:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 4,408 ms
コンパイル使用メモリ 197,632 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 14:52:29
合計ジャッジ時間 3,289 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef hari64
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define debug(...)
#else
#include "viewer.hpp"
#define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif  // clang-format off
using namespace std;constexpr int INF=1001001001;constexpr long long INFll=1001001001001001001;
template<class T>bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>bool chmin(T&a,const T&b){return a>b?a=b,1:0;}  // clang-format on

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    long long N;
    cin >> N;

    long long ans = 0;

    for (long long a = 0; a < 10; a++) {
        for (long long b = 0; b < 10; b++) {
            if (a == b) continue;
            auto is_ok = [&](long long p) -> bool {
                return (a * p + b) * N > p * p - 1;
            };
            long long ok, ng;
            ok = -1;
            ng = INF;
            while (abs(ok - ng) > 1) {
                long long mid = (ok + ng) / 2;
                if (is_ok(mid)) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            chmin(ok, 1000000000ll);
            ok -= max(a, b);
            if (ok > 0) ans += ok;
        }
    }

    cout << ans << endl;

    return 0;
}
0