結果

問題 No.473 和と積の和
ユーザー chaemonchaemon
提出日時 2016-12-23 01:01:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 3,000 ms
コード長 2,794 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 98,212 KB
実行使用メモリ 60,508 KB
最終ジャッジ日時 2023-08-22 08:24:41
合計ジャッジ時間 5,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
37,212 KB
testcase_01 AC 14 ms
37,196 KB
testcase_02 AC 11 ms
37,308 KB
testcase_03 AC 45 ms
53,872 KB
testcase_04 AC 13 ms
37,268 KB
testcase_05 AC 11 ms
37,260 KB
testcase_06 AC 11 ms
37,260 KB
testcase_07 AC 11 ms
37,208 KB
testcase_08 AC 11 ms
37,336 KB
testcase_09 AC 16 ms
37,252 KB
testcase_10 AC 107 ms
37,152 KB
testcase_11 AC 224 ms
37,236 KB
testcase_12 AC 11 ms
37,356 KB
testcase_13 AC 13 ms
37,416 KB
testcase_14 AC 16 ms
37,328 KB
testcase_15 AC 18 ms
37,392 KB
testcase_16 AC 18 ms
37,344 KB
testcase_17 AC 20 ms
37,328 KB
testcase_18 AC 11 ms
37,164 KB
testcase_19 AC 13 ms
37,280 KB
testcase_20 AC 180 ms
37,332 KB
testcase_21 AC 11 ms
37,260 KB
testcase_22 AC 225 ms
37,400 KB
testcase_23 AC 19 ms
39,908 KB
testcase_24 AC 26 ms
39,912 KB
testcase_25 AC 87 ms
60,508 KB
testcase_26 AC 40 ms
51,704 KB
testcase_27 AC 48 ms
51,776 KB
testcase_28 AC 225 ms
37,284 KB
testcase_29 AC 30 ms
37,352 KB
testcase_30 AC 27 ms
37,276 KB
testcase_31 AC 25 ms
37,320 KB
testcase_32 AC 23 ms
37,336 KB
testcase_33 AC 16 ms
37,324 KB
testcase_34 AC 70 ms
54,096 KB
testcase_35 AC 64 ms
54,088 KB
testcase_36 AC 70 ms
37,408 KB
testcase_37 AC 18 ms
37,320 KB
testcase_38 AC 59 ms
54,100 KB
testcase_39 AC 46 ms
49,428 KB
testcase_40 AC 49 ms
49,456 KB
testcase_41 AC 287 ms
49,468 KB
testcase_42 AC 39 ms
58,332 KB
testcase_43 AC 45 ms
58,300 KB
testcase_44 AC 50 ms
58,536 KB
testcase_45 AC 16 ms
37,348 KB
testcase_46 AC 12 ms
37,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N,X;

int dp[2][2000][2000];
int sum[2][2000][2000];
vector<vector<pii> > v;

int main(){
	cin>>N>>X;
	X++;
	vector<int> divs;
	for(int d=1;d*d<=X;d++){
		if(X%d==0){
			divs.push_back(d);
			if(d*d<X)divs.push_back(X/d);
		}
	}
	sort(ALL(divs));
	v.assign(divs.size(),vector<pii>());
	REP(i,divs.size()){
		for(int d=1;d*d<=divs[i];d++){
			if(divs[i]%d==0){
				v[i].push_back(make_pair(
							distance(divs.begin(),lower_bound(ALL(divs),d)),
							distance(divs.begin(),lower_bound(ALL(divs),divs[i]/d))));
			}
		}
	}
//	cerr<<" "<<divs.size()<<endl;
//	map<int,int> dp[2];//product, end
	dp[0][0][0] = 1;
	REP(n,N){
		int from = n%2, to = (n+1)%2;
		memset(dp[to],0,sizeof(dp[to]));
//		dp[to].clear();
		REP(i,divs.size()){
			int s = 0;
			REP(u,divs.size()){
				s+=dp[from][i][u];
				sum[from][i][u] = s;
			}
		}

		REP(i,divs.size()){
			for(auto pr:v[i]){
				if(pr.second!=0)dp[to][i][pr.second]+=sum[from][pr.first][pr.second];
				if(pr.first!=pr.second and pr.first!=0){
					dp[to][i][pr.first]+=sum[from][pr.second][pr.first];
				}
			}
		}
		/*
		if(N==2){
			REP(i,divs.size()){
				REP(j,divs.size()){
					cerr<<dp[to][i][j]<<" ";
				}
				cerr<<endl;
			}
			cerr<<endl;
		}
		*/
	}
	int ans = 0;
	for(int i=1;i<divs.size();i++){
		ans+=dp[N%2][divs.size()-1][i];
	}
	cout<<ans<<endl;
	return 0;
}
0