結果

問題 No.864 四方演算
ユーザー firiexpfiriexp
提出日時 2019-08-16 21:42:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 905 bytes
コンパイル時間 1,121 ms
コンパイル使用メモリ 100,404 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 21:33:46
合計ジャッジ時間 2,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>


static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
vector<T> divisor(T n){
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main() {
    ll n, k;
    cin >> n >> k;
    auto v = divisor(k);
    ll ans = 0;
    for (auto &&i : v) {
        auto j = k/i;
        ans +=  min(i-1, max(0LL, n-abs(n+1-i)))*min(j-1, max(0LL, n-abs(n+1-j)));
    }
    cout << ans << "\n";
    return 0;
}
0