結果

問題 No.1532 Different Products
ユーザー HaaHaa
提出日時 2021-06-04 21:26:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 337 ms / 4,000 ms
コード長 1,055 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 183,164 KB
実行使用メモリ 17,580 KB
最終ジャッジ日時 2023-08-12 11:37:29
合計ジャッジ時間 16,395 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 51 ms
6,248 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 22 ms
4,376 KB
testcase_10 AC 70 ms
5,152 KB
testcase_11 AC 58 ms
4,632 KB
testcase_12 AC 153 ms
9,672 KB
testcase_13 AC 114 ms
5,176 KB
testcase_14 AC 241 ms
17,304 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 63 ms
10,720 KB
testcase_17 AC 62 ms
4,532 KB
testcase_18 AC 49 ms
4,724 KB
testcase_19 AC 145 ms
8,264 KB
testcase_20 AC 237 ms
15,204 KB
testcase_21 AC 90 ms
12,156 KB
testcase_22 AC 99 ms
5,716 KB
testcase_23 AC 68 ms
4,764 KB
testcase_24 AC 223 ms
14,532 KB
testcase_25 AC 127 ms
10,212 KB
testcase_26 AC 19 ms
4,376 KB
testcase_27 AC 123 ms
14,692 KB
testcase_28 AC 91 ms
9,724 KB
testcase_29 AC 98 ms
16,068 KB
testcase_30 AC 158 ms
17,172 KB
testcase_31 AC 153 ms
16,508 KB
testcase_32 AC 173 ms
16,864 KB
testcase_33 AC 142 ms
15,576 KB
testcase_34 AC 215 ms
15,804 KB
testcase_35 AC 174 ms
16,296 KB
testcase_36 AC 205 ms
17,420 KB
testcase_37 AC 79 ms
16,248 KB
testcase_38 AC 218 ms
16,484 KB
testcase_39 AC 193 ms
16,020 KB
testcase_40 AC 204 ms
16,252 KB
testcase_41 AC 275 ms
16,736 KB
testcase_42 AC 244 ms
16,560 KB
testcase_43 AC 268 ms
16,432 KB
testcase_44 AC 280 ms
17,384 KB
testcase_45 AC 277 ms
17,580 KB
testcase_46 AC 273 ms
17,488 KB
testcase_47 AC 277 ms
17,420 KB
testcase_48 AC 277 ms
17,420 KB
testcase_49 AC 322 ms
17,356 KB
testcase_50 AC 319 ms
17,512 KB
testcase_51 AC 325 ms
17,520 KB
testcase_52 AC 310 ms
17,388 KB
testcase_53 AC 319 ms
17,356 KB
testcase_54 AC 316 ms
17,576 KB
testcase_55 AC 328 ms
17,360 KB
testcase_56 AC 312 ms
17,436 KB
testcase_57 AC 322 ms
17,580 KB
testcase_58 AC 337 ms
17,360 KB
testcase_59 AC 263 ms
17,576 KB
testcase_60 AC 291 ms
17,504 KB
testcase_61 AC 2 ms
4,376 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 277 ms
17,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    ll n, k; cin >> n >> k;
    VVI dp(n+10);
    for(ll i=n;i>=1;i--){
        dp[i]=dp[i+1];
        dp[i].push_back(i);
        for(int j=i+1;j<=n;j++){
            dp[i].push_back(i*j);
        }
        sort(ALL(dp[i]));
    }
    unordered_map<ll,ll> mp; mp[1]=1;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        unordered_map<ll,ll> nxmp;
        for(auto p:mp){
            if(p.first*i*(i+1)*(i+2)<=k){
                nxmp[p.first]+=p.second;
                nxmp[p.first*i]+=p.second;
            }
            else{
                ans+=p.second;
                ans+=p.second*(upper_bound(ALL(dp[i]),k/p.first)-dp[i].begin());
            }
        }
        mp=nxmp;
    }
    for(auto p:mp){
        ans+=p.second;
    }
    cout << ans-1 << endl;
    return 0;
}
0