当前位置:网站首页>D - I Hate Non-integer Number (count of selected number dp
D - I Hate Non-integer Number (count of selected number dp
2022-08-05 00:21:00 【__Rain】
D - I Hate Non-integer Number
思路:
枚举选 l l l 个数,然后 d p [ i ] [ j ] [ k ] dp[i][j][k] dp[i][j][k] 表示前 i i i 个数选 j j j 个数 % l \%l %l 的和为 k k k 的方案数
那么答案就是所有 l l l 情况下的 d p [ n ] [ l ] [ 0 ] dp[n][l][0] dp[n][l][0] 的加和
code:
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(), x.end()
#define mem(x, d) memset(x, d, sizeof(x))
#define eps 1e-6
using namespace std;
const int maxn = 2e6 + 9;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
ll n, m;
int a[109];
ll dp[109][109][109];
// 前i个数选j个,和 %l 为 k 的方案数
ll ans = 0;
void work()
{
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
for(int l = 1; l <= n; ++l)
{
mem(dp, 0);
dp[0][0][0] = 1;
for(int i = 1; i <= n; ++i){
for(int j = 0; j <= i; ++j)
for(int k = 0; k < l; ++k)
dp[i][j][k] = dp[i-1][j][k];// don't choosea_iShift the situation
for(int j = 0; j <= i; ++j){
for(int k = 0; k < l; ++k){
if(j >= 1){
int sum = (a[i] + k) % l;
(dp[i][j][sum] += dp[i-1][j-1][k]) %= mod;
}
}
}
}
(ans += dp[n][l][0]) %= mod;
}
cout << ans;
}
int main()
{
ios::sync_with_stdio(0);
// int TT;cin>>TT;while(TT--)
work();
return 0;
}
边栏推荐
- oracle创建用户以后的权限问题
- IDEA file encoding modification
- E - Many Operations (bitwise consideration + dp thought to record the result after the operation
- tiup uninstall
- Essential knowledge for entry-level 3D game modelers
- 软件测试面试题:软件测试类型都有哪些?
- Metasploit-域名上线隐藏IP
- E - Distance Sequence (前缀和优化dp
- Raw and scan of gorm
- 测试经理要不要做测试执行?
猜你喜欢

Statistical words (DAY 101) Huazhong University of Science and Technology postgraduate examination questions

Three tips for you to successfully get started with 3D modeling

电赛必备技能___定时ADC+DMA+串口通信

The master teaches you the 3D real-time character production process, the game modeling process sharing

进程间通信和线程间通信

Will domestic websites use Hong Kong servers be blocked?

性能测试如何准备测试数据
![[230]连接Redis后执行命令错误 MISCONF Redis is configured to save RDB snapshots](/img/fa/5bdc81b1ebfc22d31f42da34427f3e.png)
[230]连接Redis后执行命令错误 MISCONF Redis is configured to save RDB snapshots

子连接中的参数传递

gorm联表查询-实战
随机推荐
电赛必备技能___定时ADC+DMA+串口通信
Cloud native - Kubernetes 】 【 scheduling constraints
leetcode:267. 回文排列 II
tiup update
could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
IDEA 文件编码修改
RK3399平台开发系列讲解(内核调试篇)2.50、嵌入式产品启动速度优化
#yyds dry goods inventory #Switching equipment serious packet loss troubleshooting
leetcode经典例题——单词拆分
oracle创建用户以后的权限问题
机器学习(公式推导与代码实现)--sklearn机器学习库
Mysql_12 多表查询
First, the basic concept of reptiles
2022杭电多校第三场 L题 Two Permutations
2022 Hangzhou Electric Multi-School 1004 Ball
Software Testing Interview Questions: What aspects should be considered when designing test cases, i.e. what aspects should different test cases test against?
ansible学习笔记分享-含剧本示例
仿网易云音乐小程序-uniapp
gorm的Raw与scan
2022 Niu Ke Summer Multi-School Training Camp 5 (BCDFGHK)