結果

問題 No.473 和と積の和
ユーザー 👑 kmjpkmjp
提出日時 2016-12-23 00:25:50
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,296 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 159,248 KB
実行使用メモリ 34,676 KB
最終ジャッジ日時 2023-08-22 07:21:58
合計ジャッジ時間 17,830 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,480 KB
testcase_01 AC 5 ms
10,736 KB
testcase_02 AC 5 ms
10,496 KB
testcase_03 AC 725 ms
18,676 KB
testcase_04 AC 5 ms
10,480 KB
testcase_05 AC 4 ms
10,444 KB
testcase_06 AC 5 ms
10,496 KB
testcase_07 AC 5 ms
10,544 KB
testcase_08 AC 4 ms
10,548 KB
testcase_09 AC 5 ms
10,532 KB
testcase_10 AC 4 ms
10,528 KB
testcase_11 AC 5 ms
10,776 KB
testcase_12 AC 4 ms
10,432 KB
testcase_13 AC 4 ms
10,448 KB
testcase_14 AC 5 ms
10,452 KB
testcase_15 AC 5 ms
10,556 KB
testcase_16 AC 5 ms
10,680 KB
testcase_17 AC 5 ms
10,624 KB
testcase_18 AC 5 ms
10,584 KB
testcase_19 AC 4 ms
10,532 KB
testcase_20 AC 4 ms
10,448 KB
testcase_21 AC 5 ms
10,532 KB
testcase_22 AC 5 ms
10,492 KB
testcase_23 AC 8 ms
10,732 KB
testcase_24 AC 10 ms
10,856 KB
testcase_25 TLE -
testcase_26 AC 495 ms
16,652 KB
testcase_27 AC 736 ms
19,136 KB
testcase_28 AC 5 ms
10,444 KB
testcase_29 AC 6 ms
10,520 KB
testcase_30 AC 6 ms
10,756 KB
testcase_31 AC 5 ms
10,508 KB
testcase_32 AC 5 ms
10,580 KB
testcase_33 AC 5 ms
10,512 KB
testcase_34 AC 1,884 ms
28,220 KB
testcase_35 AC 1,869 ms
27,572 KB
testcase_36 AC 6 ms
10,764 KB
testcase_37 AC 5 ms
10,472 KB
testcase_38 AC 1,818 ms
26,936 KB
testcase_39 AC 907 ms
21,112 KB
testcase_40 AC 949 ms
21,688 KB
testcase_41 AC 990 ms
22,816 KB
testcase_42 AC 20 ms
10,684 KB
testcase_43 AC 271 ms
13,076 KB
testcase_44 AC 725 ms
16,948 KB
testcase_45 AC 5 ms
10,440 KB
testcase_46 AC 5 ms
10,480 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 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(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;
	
	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