結果

問題 No.473 和と積の和
ユーザー 👑 kmjpkmjp
提出日時 2016-12-23 00:25:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,283 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 172,504 KB
実行使用メモリ 18,216 KB
最終ジャッジ日時 2024-05-09 13:15:18
合計ジャッジ時間 9,021 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,320 KB
testcase_01 AC 5 ms
10,412 KB
testcase_02 AC 5 ms
10,424 KB
testcase_03 AC 2,449 ms
18,216 KB
testcase_04 AC 5 ms
10,464 KB
testcase_05 AC 4 ms
10,380 KB
testcase_06 AC 6 ms
10,424 KB
testcase_07 AC 4 ms
10,464 KB
testcase_08 AC 5 ms
10,400 KB
testcase_09 AC 5 ms
10,316 KB
testcase_10 AC 5 ms
10,404 KB
testcase_11 AC 5 ms
10,408 KB
testcase_12 AC 4 ms
10,420 KB
testcase_13 AC 5 ms
10,336 KB
testcase_14 AC 4 ms
10,444 KB
testcase_15 AC 4 ms
10,468 KB
testcase_16 AC 5 ms
10,488 KB
testcase_17 AC 5 ms
10,428 KB
testcase_18 AC 4 ms
10,416 KB
testcase_19 AC 5 ms
10,468 KB
testcase_20 AC 5 ms
10,476 KB
testcase_21 AC 4 ms
10,360 KB
testcase_22 AC 5 ms
10,440 KB
testcase_23 AC 10 ms
10,628 KB
testcase_24 AC 17 ms
10,800 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

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 dfs(int left,int id,ll v) {
	if(left==0) return v==X;
	if(memo[left][id].count(v)) return memo[left][id][v];
	ll ret=0;
	
	int x;
	for(x=id;x<V.size();x++) if(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;
	
	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