結果

問題 No.864 四方演算
ユーザー ゆきのんゆきのん
提出日時 2019-08-16 23:18:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 882 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 165,740 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 05:17:59
合計ジャッジ時間 5,468 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}



int main(){
    LL n,k;cin >> n >> k;
    auto p = divi(k);
    LL ans = 0;
    for(auto q:p){
        LL t = k/q;
        LL ca = max(0LL,min(q-1,n) - max(q-n,1LL) + 1);
        LL cb = max(0LL,min(t-1,n) - max(t-n,1LL) + 1);
        ans += ca*cb;
    }
    cout << ans << endl;
    return 0;
}
0