結果

問題 No.864 四方演算
ユーザー Konton7
提出日時 2020-02-04 01:51:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 813 bytes
コンパイル時間 2,441 ms
コンパイル使用メモリ 192,480 KB
最終ジャッジ日時 2025-01-08 22:01:10
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, k, ans, a, b, c;
    cin >> n >> k;

    ans = 0;

    rep(i, sqrt(k))
    {
        if (k % (i + 1) == 0)
        {
            a = i + 1, b = k / (i + 1);
            c = (a == b) ? 1 : 2;
            if (a > 1)
            {
                ans += max(0ll, min(2 * n - a + 1, a - 1)) * max(0ll, min(2 * n - b + 1, b - 1)) * c;
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0