結果

問題 No.1143 面積Nの三角形
ユーザー chielochielo
提出日時 2020-08-01 01:13:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 800 ms
コード長 976 bytes
コンパイル時間 1,604 ms
コンパイル使用メモリ 168,564 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 05:01:14
合計ジャッジ時間 3,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;
const int maxn = 2e6 + 3;

std::vector<ll> d;

int main() {
    ll n;
    scanf("%lld", &n);
    for(ll i = 1; i <= n; ++i) {
        if((n * n) % i)
            continue;
        d.push_back(i);
    }
    for(ll i = n - 1; i >= 1; --i) {
        if((n * n) % i)
            continue;
        d.push_back(n * n / i);
    }
    ll ans = 0;
    for(auto &&x : d) {
        for(auto &&y : d) {
            if(y > x || x > n * n / y)
                break;
            double b = x * y * (double)(x + y);
            double d2 = b * b + 4. * n * n * x * y;
            double d = sqrt(d2);
            ll l = (-b + d) / (double)(2. * x * y);
            for(ll z = std::max(x, l - 1ll); z <= l + 1ll; ++z) {
                if(z * y <= n * n / x && z * (x + y + z) * y == n * n / x) {
                    ans += 1;
                    break;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}
0