結果

問題 No.473 和と積の和
ユーザー 👑 kmjpkmjp
提出日時 2016-12-23 00:27:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 509 ms / 3,000 ms
コード長 1,417 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 159,792 KB
実行使用メモリ 13,208 KB
最終ジャッジ日時 2023-08-22 08:24:28
合計ジャッジ時間 5,816 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,552 KB
testcase_01 AC 5 ms
10,488 KB
testcase_02 AC 5 ms
10,552 KB
testcase_03 AC 262 ms
12,428 KB
testcase_04 AC 5 ms
10,492 KB
testcase_05 AC 4 ms
10,480 KB
testcase_06 AC 4 ms
10,548 KB
testcase_07 AC 5 ms
10,592 KB
testcase_08 AC 4 ms
10,532 KB
testcase_09 AC 5 ms
10,540 KB
testcase_10 AC 4 ms
10,484 KB
testcase_11 AC 5 ms
10,492 KB
testcase_12 AC 4 ms
10,512 KB
testcase_13 AC 5 ms
10,560 KB
testcase_14 AC 5 ms
10,508 KB
testcase_15 AC 5 ms
10,784 KB
testcase_16 AC 5 ms
10,532 KB
testcase_17 AC 5 ms
10,512 KB
testcase_18 AC 5 ms
10,684 KB
testcase_19 AC 5 ms
10,492 KB
testcase_20 AC 4 ms
10,568 KB
testcase_21 AC 5 ms
10,488 KB
testcase_22 AC 5 ms
10,752 KB
testcase_23 AC 6 ms
10,624 KB
testcase_24 AC 5 ms
10,672 KB
testcase_25 AC 184 ms
12,240 KB
testcase_26 AC 177 ms
12,152 KB
testcase_27 AC 98 ms
11,712 KB
testcase_28 AC 5 ms
10,520 KB
testcase_29 AC 5 ms
10,652 KB
testcase_30 AC 5 ms
10,588 KB
testcase_31 AC 5 ms
10,568 KB
testcase_32 AC 5 ms
10,568 KB
testcase_33 AC 5 ms
10,704 KB
testcase_34 AC 50 ms
11,500 KB
testcase_35 AC 156 ms
12,124 KB
testcase_36 AC 5 ms
10,516 KB
testcase_37 AC 5 ms
10,516 KB
testcase_38 AC 249 ms
12,288 KB
testcase_39 AC 155 ms
11,956 KB
testcase_40 AC 118 ms
11,884 KB
testcase_41 AC 6 ms
11,060 KB
testcase_42 AC 21 ms
11,700 KB
testcase_43 AC 243 ms
12,712 KB
testcase_44 AC 509 ms
13,208 KB
testcase_45 AC 5 ms
10,568 KB
testcase_46 AC 5 ms
10,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,X;
vector<ll> V;
map<int,int> R;

map<int,int> memo[101][1500];
ll P[1500][105];


ll dfs(int left,int id,ll v) {
	if(left==0) return v==X;
	if(memo[left][id].count(v)) return memo[left][id][v];
	if(v*P[id][left]>X) return 0;
	ll ret=0;
	
	int x;
	for(x=id;x<V.size();x++) if(v*V[x]<=X && R.count(v*V[x])) ret += dfs(left-1,x,v*V[x]);
	
	return memo[left][id][v]=ret;
	
}

vector<ll> enumdiv(ll n) {
	vector<ll> S;
	for(ll i=1;i*i<=n;i++) if(n%i==0) {S.push_back(i); if(i*i!=n) S.push_back(n/i); }
	sort(S.begin(),S.end());
	return S;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	X++;
	V=enumdiv(X);
	FOR(i,V.size()) {
		R[V[i]]=i;
		P[i][0]=1;
		FOR(x,100) P[i][x+1]=min(P[i][x]*V[i],1LL<<30);
	}
	
	
	cout<<dfs(N,1,1)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0