From 9f190cb94cef1d2856b900332eee3288224713a6 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Fri, 14 Nov 2025 17:05:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(P3102):=20=E4=BF=AE=E6=AD=A3=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=A7=84=E5=88=92=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=92=8C=E8=BE=93=E5=87=BA=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将加法操作改为乘法操作以正确计算组合数,并简化输出结果的格式 --- src/11/13/P3102.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/11/13/P3102.cpp b/src/11/13/P3102.cpp index d6117a0..398ea3e 100644 --- a/src/11/13/P3102.cpp +++ b/src/11/13/P3102.cpp @@ -34,12 +34,12 @@ static inline ll dfs(const ll l,const ll r){ for(ll j=0;jr-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p; + dp[l][r]=(dfs(l, i-1)*dfs(i, r)%p+dp[l][r])%p; nxt1:; for(ll j=0;jr-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p; + dp[l][r]=(dfs(l, i-1)*dfs(i, r)%p+dp[l][r])%p; nxt2:; } return dp[l][r]; @@ -53,5 +53,5 @@ int main(){ n=s.size(); s=' '+s; dp.resize(n+1,std::vector(n+1)); - std::cout<<(dfs(1,n)-1+p)%p<<"\n"; + std::cout<