結果
| 問題 |
No.473 和と積の和
|
| コンテスト | |
| ユーザー |
chaemon
|
| 提出日時 | 2016-12-23 01:01:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,794 bytes |
| コンパイル時間 | 1,242 ms |
| コンパイル使用メモリ | 104,788 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-12-16 02:55:13 |
| 合計ジャッジ時間 | 3,558 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 39 RE * 4 |
ソースコード
// #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][1000][1000];
int sum[2][1000][1000];
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;
}
chaemon