結果

問題 No.1532 Different Products
ユーザー noya2noya2
提出日時 2021-06-04 21:48:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,063 bytes
コンパイル時間 4,314 ms
コンパイル使用メモリ 274,152 KB
実行使用メモリ 188,800 KB
最終ジャッジ日時 2024-04-30 02:23:29
合計ジャッジ時間 17,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 TLE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 TLE -
testcase_39 WA -
testcase_40 WA -
testcase_41 TLE -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using bint = mp::cpp_int;
*/
#include <atcoder/all>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define repp(i,n,m) for (int i = m; i < int(n); ++i)
using namespace std;
using namespace atcoder;
using namespace internal;
//alias g++='g++ -I/mnt/c/Users/Owner/Desktop/ac-library'
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PI = pair<pair<int,int>,int>;
using PL = pair<long long, long long>;
using PLL = pair<pair<long long, long long>, long long>;
using Pxy = pair<long double, long double>;
const int INF = 1001001007;
const int modd = 1000000007;
const long long modl = 1000000007LL;
const long long mod = 998244353LL;
const ll inf = 2e18;

template <typename SA>
void priv(vector<SA> &ar){
    if (ar.size() == 0) cout << endl;
    else {
        rep(i,ar.size()-1) cout << ar[i] << " ";
        cout << ar[ar.size()-1] << endl;
    } 
}
template <typename SB>
void privv(vector<vector<SB>> &ar){
    rep(i,ar.size()){
        rep(j,ar[i].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[i].size()-1] << endl;
    }
}
template <typename SC>
bool range(SC a, SC b, SC x){return (a <= x && x < b);}
bool rrange(P a, P b, P xy){
    bool s = range(a.first,b.first,xy.first);
    bool t = range(a.second,b.second,xy.second);
    return (s && t);
}
template <typename SD>
void sor(vector<SD> &ar){sort(ar.begin(),ar.end());}
template <typename SE>
void rev(vector<SE> &ar){reverse(ar.begin(),ar.end());}
template <typename SF>
bool chmin(SF &a, const SF &b){if(a>b){a = b; return true;} return false;}
template <typename SG>
bool chmax(SG &a, const SG &b){if(a<b){a = b; return true;} return false;}
template <typename SH>
void eru(vector<SH> &ar){sor(ar);ar.erase(unique(ar.begin(),ar.end()),ar.end());}
template <typename SI>
SI   last(vector<SI> &ar){return ar[ar.size()-1];}
template <typename SJ>
SJ   cel(SJ a, SJ b){if (a % b == 0) return a/b; return a/b +1;}
template <typename SK, typename SL>
void pout(pair<SK,SL> p) {cout << p.first << " " << p.second << endl;}

void yes(){cout << "Yes" << endl;}
void no (){cout << "No" << endl;}
void yn (bool t){if(t)yes();else no();}
void Yes(){cout << "YES" << endl;}
void No (){cout << "NO" << endl;}
void YN (bool t){if(t)Yes();else No();}
void dout() {cout << setprecision(20);}

vector<int> dx = {0,1,0,-1};
vector<int> dy = {1,0,-1,0};
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string alp = "abcdefghijklmnopqrstuvwxyz";

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll cnt(vector<ll> &ar, ll x){
    ll le = -1;
    ll ri = ar.size();
    ll mid = (le + ri) / 2;
    while (ri - le > 1){
        if (ar[mid] <= x) le = mid;
        else ri = mid;
        mid = (le + ri) / 2;
    }
    return le + 1;
}

ll slv(vector<ll> &ar, ll n, ll k, map<PL,ll> &mp){
    if (mp.find(PL(n,k)) != mp.end()) return mp[PL(n,k)];
    if (n == 13) return mp[PL(n,k)] = cnt(ar,k);
    if (k == 1) return mp[PL(n,k)] = 1;
    if (n > k) return mp[PL(n,k)] = slv(ar,max(13LL,k),k,mp);
    return mp[PL(n,k)] = slv(ar,n-1,k,mp) + slv(ar,n-1,k/n,mp);
}

int main(){
    int n; cin >> n;
    ll k; cin >> k;
    vector<ll> kai(14,1);
    repp(i,14,2) kai[i] = kai[i-1] * i;
    if (n <= 13){
        vector<ll> ar(1<<n);
        rep(i,1<<n){
            ll h = 1;
            rep(j,n) if (i >> j & 1) h *= j+1;
            ar[i] = h;
        }
        sor(ar);
        cout << cnt(ar,k) - 1 << endl;
    }
    else {
        vector<ll> ar(1<<13);
        rep(i,1<<13){
            ll h = 0;
            rep(j,13) if (i >> j & 1) h *= j+1;
            ar[i] = h;
        }
        sor(ar);
        map<PL,ll> mp;
        cout << slv(ar,n,k,mp) - 1 << endl;
    }
}
0