結果

問題 No.473 和と積の和
ユーザー koba-e964koba-e964
提出日時 2016-12-23 03:11:32
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,558 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 99,316 KB
実行使用メモリ 687,596 KB
最終ジャッジ日時 2023-08-22 07:33:10
合計ジャッジ時間 7,408 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,972 KB
testcase_01 AC 3 ms
5,744 KB
testcase_02 AC 3 ms
5,588 KB
testcase_03 AC 896 ms
167,104 KB
testcase_04 AC 3 ms
5,536 KB
testcase_05 AC 4 ms
5,532 KB
testcase_06 AC 3 ms
5,656 KB
testcase_07 AC 3 ms
5,596 KB
testcase_08 AC 3 ms
5,588 KB
testcase_09 AC 3 ms
5,556 KB
testcase_10 AC 3 ms
5,604 KB
testcase_11 AC 3 ms
5,804 KB
testcase_12 AC 3 ms
5,588 KB
testcase_13 AC 3 ms
5,628 KB
testcase_14 AC 3 ms
5,604 KB
testcase_15 AC 3 ms
5,696 KB
testcase_16 AC 4 ms
5,700 KB
testcase_17 AC 3 ms
5,728 KB
testcase_18 AC 3 ms
5,608 KB
testcase_19 AC 3 ms
5,608 KB
testcase_20 AC 3 ms
5,584 KB
testcase_21 AC 3 ms
5,552 KB
testcase_22 AC 3 ms
5,604 KB
testcase_23 AC 10 ms
7,748 KB
testcase_24 AC 20 ms
10,420 KB
testcase_25 MLE -
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 <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int F = 1500;
const int N = 31;
map<ll, ll> memo[F][N];

ll solve(const VL &fact, int k, int rem, ll x) {
  if (x == 1) {
    return rem <= 0 ? 1 : 0;
  }
  if (k >= fact.size()) {
    return 0;
  }
  if (rem <= 0) {
    return 0;
  }
  ll f = fact[k];
  if (rem == 1) {
    return x >= f ? 1 : 0;
  }
  if (memo[k][rem].count(x) == 0) {
    memo[k][rem][x] = 0;
  } else {
    return memo[k][rem][x];
  }
  ll &ret = memo[k][rem][x];
  if (x % f == 0) {
    ret += solve(fact, k, rem - 1, x / f);
  }
  ret += solve(fact, k + 1, rem, x);
  return ret;
}

int main(void){
  int n;
  ll x;
  cin >> n >> x;
  x += 1;
  if (n >= 30) {
    cout << 0 << endl;
    return 0;
  }
  VL fact;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      if (i > 1) {
	fact.push_back(i);
      }
      if (x != i * i) {
	fact.push_back(x / i);
      }
    }
  }
  sort(fact.begin(), fact.end());
  cout << solve(fact, 0, n, x) << endl;
}
0