diff --git a/src/11/29/P1077/P1077.cpp b/src/11/29/P1077/P1077.cpp new file mode 100644 index 0000000..b7adfc3 --- /dev/null +++ b/src/11/29/P1077/P1077.cpp @@ -0,0 +1,34 @@ +#include +#include +using namespace std; + +typedef long long ll; + +const int MOD = 1000007; + +int main(){ + int n, m; + cin >> n >> m; + vector a(n); + for(auto &x: a) cin >> x; + + // dp[j] 表示当前总数为 j 的方案数 + vector dp(m+1, 0); + dp[0] = 1; + + for(int i=0; i new_dp(m+1, 0); + for(int j=0; j<=m; ++j){ + if(dp[j] == 0) continue; + // 尝试摆放 k 盆当前类型的花 + for(int k=0; k<=a[i] && j + k <= m; ++k){ + new_dp[j + k] = (new_dp[j + k] + dp[j]) % MOD; + } + } + dp = new_dp; + } + + cout << dp[m] % MOD; + return 0; +} diff --git a/src/11/29/P4084/P4084.cpp b/src/11/29/P4084/P4084.cpp new file mode 100644 index 0000000..fe6865a --- /dev/null +++ b/src/11/29/P4084/P4084.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include +using namespace std; +using ll = int64_t; + +ll const maxn{2500+5}; +ll n,ans; +array t,tmp; +vector adj[maxn]; + +void dfs(ll const& ftr, ll const& u){ + for(ll const& v:adj[u]){ + if(v==ftr)continue; + dfs(u,v); + tmp[u]+=12-tmp[v]; + tmp[u]%=12; + if(tmp[u]==0)tmp[u]=12; + } +} + +int main(){ + cin.tie(nullptr),cout.tie(nullptr),ios::sync_with_stdio(false); + + cin>>n; + for(ll i{1};i<=n;i++)cin>>t[i]; + for(ll i{1};i>u>>v; + adj[u].emplace_back(v); + adj[v].emplace_back(u); + } + + for(ll i{1};i<=n;i++){ + copy(t.data(),t.data()+1+n,tmp.data()); + dfs(0,i); + if(tmp[i]==12||tmp[i]==1){ + ans++; + } + } + cout<