結果

問題 No.473 和と積の和
ユーザー Hoi_koroHoi_koro
提出日時 2016-12-23 11:06:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,319 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 129,992 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 13:27:07
合計ジャッジ時間 4,907 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 RE -
testcase_03 AC 232 ms
5,760 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 RE -
testcase_07 AC 2 ms
5,376 KB
testcase_08 RE -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 121 ms
5,376 KB
testcase_26 AC 157 ms
5,376 KB
testcase_27 AC 78 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 21 ms
5,376 KB
testcase_35 AC 96 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 169 ms
5,888 KB
testcase_39 AC 105 ms
5,376 KB
testcase_40 AC 74 ms
5,376 KB
testcase_41 AC 3 ms
5,376 KB
testcase_42 AC 3 ms
5,376 KB
testcase_43 AC 22 ms
5,376 KB
testcase_44 AC 326 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

//make_tuple emplace_back next_permutation
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(...) string s999;s999=#__VA_ARGS__;replace(ALL(s999),',',' ');stringstream ds999; ds999<<s999; debug(ds999,__VA_ARGS__);
inline void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<' '<<f<<' '; debug(ds,r...);}
#define ALL(v) (v).begin(),(v).end()
#define SI(v) (int)(v).size()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

VLL divisor;
LL n,x;
map<tuple<int,LL,LL>,int> dp;
void pre(long long k){
    for(long long  i=2; ;++i){
        if(i*i>k){
            break;
        }
        if(k%i==0){
            divisor.push_back(i);
            if(i*i<k)divisor.push_back(k/i);
        }
    }
    return;
}

int calc(int a, LL m, LL p){
    int ret=0;
    auto it=dp.find(make_tuple(a,divisor[m],p));
    if(it!=dp.end()){
        return it->second;
    }
    if(a==n-1){
        if(x/p>=divisor[m] and x%(x/p)==0) return 1;
        else return 0;
    }
    for(auto it = divisor.begin()+m; it<divisor.end(); ++it){
        //DBG(p,*it,log(x/p)/log(*it),(double)n-a+1)
        if(log(x/p)/log(*it)<(double)n-a-1)break;
        if((x/p)%*it==0) ret+=calc(a+1,it-divisor.begin(),p*(*it));
    }
    return dp[make_tuple(a,divisor[m],p)]=ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x;
    ++x;
    pre(x);
    sort(ALL(divisor));
    cout << calc(0,0,1)<<endl;

    return 0;
}
0