結果

問題 No.864 四方演算
ユーザー WarToksWarToks
提出日時 2019-08-16 21:55:17
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 1,118 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 93,036 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 12:43:31
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 12 ms
4,376 KB
testcase_02 AC 9 ms
4,380 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 10 ms
4,380 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 11 ms
4,376 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 9 ms
4,380 KB
testcase_22 AC 9 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <cstring>


#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define eREP(i, n) for(int (i) = 0; (i) <= (n); ++(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;}
template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;}

using lli = long long int;





int main(void){
    lli n, k; std::cin >> n >> k;
    // (a + c)(b + d) = K
    lli res = 0;
    for(lli x = 2; x * x <= k; x++) if(k % x == 0){
        lli y = k / x;
        if(not(2 <= x and x <= 2 * n and 2 <= y and y <= 2 * n)) continue;
        // a + c = x
        // b + d = y
        // c = x - a -> 1 ≤ x - a ≤ N => x - N ≤ a ≤ x - 1
        lli L = x - n; if(L < 1) L = 1;
        lli U = x - 1; if(U > n) U = n;
        lli A = U - L + 1;
        L = y - n; if(L < 1) L = 1;
        U = y - 1; if(U > n) U = n;
        lli B = U - L + 1;
        if(x == y) res += A * B;
        else res += 2 * A * B;
    }
    std::cout << res  << '\n';
    return 0;
}
0