結果

問題 No.1143 面積Nの三角形
ユーザー fastmathfastmath
提出日時 2020-07-31 21:59:11
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 607 ms / 800 ms
コード長 1,965 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 135,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 23:14:21
合計ジャッジ時間 5,990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int INF = 2e18;
int mul(int a, int b) {
    if (a == 0 || b == 0)
        return 0;
    if (INF / a < b)
        return INF;
    else
        return a * b;
}

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    
    int m = n * n;

    vector <int> d;
    for (int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            d.app(i);
            if (i * i != m)
                d.app(m/i);
        }   
    }   
    sort(all(d));

    int ans = 0;
    for (int i = 0; mul(mul(d[i], d[i]), mul(d[i], d[i])) <= m; ++i) {
        for (int j = i; j < d.size() && mul(mul(d[i], d[j]), mul(d[j], d[j])) <= m; ++j) {
            for (int k = j; k < d.size() && mul(mul(d[i], d[j]), mul(d[k], d[k])) <= m; ++k) {

                int tot = mul(d[i], mul(d[j], d[k]));
                if (m % tot == 0) {
                    int p = m / tot;
                    if (d[k] < p) {
                        int a = p - d[k];
                        int b = p - d[j];
                        int c = p - d[i];

                        assert(a <= b);
                        assert(b <= c);

                        if (2 * p == a + b + c && a + b > c) {
                            ++ans;
                            //cout << a << ' ' << b << ' ' << c << endl;
                        }   
                    }   
                }   
                
            }   
        }   
    }
    cout << ans << endl;    

    #ifdef HOME
    cerr << Time << endl;
    #endif
}
0