結果

問題 No.1581 Multiple Sequence
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-01 09:43:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 5,097 ms
コンパイル使用メモリ 307,208 KB
実行使用メモリ 8,888 KB
最終ジャッジ日時 2023-09-01 09:44:03
合計ジャッジ時間 8,140 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 63 ms
7,936 KB
testcase_03 AC 70 ms
8,372 KB
testcase_04 AC 17 ms
5,260 KB
testcase_05 AC 74 ms
8,580 KB
testcase_06 AC 30 ms
6,072 KB
testcase_07 AC 16 ms
5,232 KB
testcase_08 AC 23 ms
5,524 KB
testcase_09 AC 66 ms
8,112 KB
testcase_10 AC 41 ms
6,816 KB
testcase_11 AC 8 ms
4,644 KB
testcase_12 AC 25 ms
5,784 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 71 ms
8,324 KB
testcase_15 AC 49 ms
7,216 KB
testcase_16 AC 10 ms
4,556 KB
testcase_17 AC 79 ms
8,888 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 61 ms
7,896 KB
testcase_20 AC 64 ms
8,064 KB
testcase_21 AC 70 ms
8,364 KB
testcase_22 AC 38 ms
6,644 KB
testcase_23 AC 82 ms
8,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  // r=kx (k+1)x=m 
  int m;cin>>m;
  vc<mint>dp(m+1,-1); 
  auto f=[&](auto f,int rest)->mint{
    if(rest==0)return 1;
    if(dp[rest]!=-1)return dp[rest];
    mint res=0;
    for(int i=1;i*i<=rest;i++)if(rest%i==0){
      res+=f(f,rest/i-1);
      if(i!=rest/i)res+=f(f,i-1);
    }
    return dp[rest]=res;
  };
  cout<<f(f,m).val();
}
0