結果

問題 No.1581 Multiple Sequence
ユーザー haruki_4936haruki_4936
提出日時 2021-07-03 22:23:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 1,356 bytes
コンパイル時間 6,235 ms
コンパイル使用メモリ 320,340 KB
実行使用メモリ 9,720 KB
最終ジャッジ日時 2023-09-13 04:12:30
合計ジャッジ時間 10,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 194 ms
8,660 KB
testcase_03 AC 217 ms
9,376 KB
testcase_04 AC 48 ms
5,460 KB
testcase_05 AC 228 ms
9,272 KB
testcase_06 AC 88 ms
6,448 KB
testcase_07 AC 44 ms
5,300 KB
testcase_08 AC 65 ms
5,868 KB
testcase_09 AC 203 ms
8,892 KB
testcase_10 AC 123 ms
7,252 KB
testcase_11 AC 20 ms
4,568 KB
testcase_12 AC 72 ms
6,068 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 218 ms
9,096 KB
testcase_15 AC 147 ms
7,884 KB
testcase_16 AC 27 ms
4,724 KB
testcase_17 AC 248 ms
9,636 KB
testcase_18 AC 17 ms
4,396 KB
testcase_19 AC 185 ms
8,572 KB
testcase_20 AC 197 ms
8,696 KB
testcase_21 AC 215 ms
9,152 KB
testcase_22 AC 109 ms
7,004 KB
testcase_23 AC 254 ms
9,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(long long i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;

const ll MOD = 1000000007;
const ll MAX = 2000100;
const ll inf = 8e18;
const long double pi = acos(-1);

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}
ll mod(ll a){ return a % MOD; }
ll lcm(ll a,ll b){ return (a*b)/gcd(a,b); }

ll memo[100009];
ll iscame[100009];


ll dp(ll x){
  if(iscame[x]) return memo[x];
  iscame[x] = true;

  ll ans = 0;

  for(ll i=1; i*i <= x; i++){
    if(i == 1){
      ans += 1;
      ans += dp(x-1);
      continue;
    }
    if(x % i == 0){
      if(i*i == x){
        ans += dp((x-i)/i);
        ans %= MOD;
      }
      else{
        ans += dp((x-(x/i))/(x/i));
        ans += dp((x-i)/i);
        ans %= MOD;
      }
    }
  }
  return memo[x] = ans;
}

int main(){
  ll m; cin >> m;

  memo[0] = 0;
  iscame[0] = true;
  memo[1] = 1;
  iscame[1] = true;
  cout << dp(m) << endl;

  // rep(i,m+1) cout << dp(i) << ' ';
}
0