当前位置:网站首页>D - I Hate Non-integer Number(背包dp)
D - I Hate Non-integer Number(背包dp)
2022-08-01 13:22:00 【Harris-H】
D - I Hate Non-integer Number(背包dp)
一开始想到dp,但是开了个三维数组不知道怎么转移。
实际上枚举选取的个数 i i i。
然后遍历 a a a,枚举当前选了 j j j个,模 i i i的余数为 k k k,这里用背包思想简化一维。
// Problem: D - I Hate Non-integer Number
// Contest: AtCoder - AtCoder Beginner Contest 262
// URL: https://atcoder.jp/contests/abc262/tasks/abc262_d
// Memory Limit: 1024 MB
// Time Limit: 2500 ms
// Date: 2022-07-31 23:51:13
// --------by Herio--------
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=105,M=2e4+5,inf=0x3f3f3f3f,mod=998244353;
const int hashmod[4] = {
402653189,805306457,1610612741,998244353};
#define mst(a,b) memset(a,b,sizeof a)
#define db double
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define x first
#define y second
#define pb emplace_back
#define SZ(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr)
void Print(int *a,int n){
for(int i=1;i<n;i++)
printf("%d ",a[i]);
printf("%d\n",a[n]);
}
template <typename T> //x=max(x,y) x=min(x,y)
void cmx(T &x,T y){
if(x<y) x=y;
}
template <typename T>
void cmn(T &x,T y){
if(x>y) x=y;
}
ll a[N];
ll f[N][N];
ll ans;
int main(){
int n;cin>>n;
rep(i,1,n) cin>>a[i];
rep(i,1,n){
mst(f,0);
f[0][0]=1;
for(int u=1;u<=n;u++)
for(int j=i;j;j--)
for(int k=0;k<i;k++){
(f[j][(k+a[u])%i]+=f[j-1][k])%=mod;
}
(ans+=f[i][0])%=mod;
}
cout<<ans;
return 0;
}
边栏推荐
- JMP Pro 16.0软件安装包下载及安装教程
- 批量替换Word中的表格为图片并保存
- Towhee 每周模型
- Efficiency tools to let programmers get off work earlier
- 高仿项目协作工具【Worktile】,从零带你一步步实现组织架构、网盘、消息、项目、审批等功能
- HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
- LeetCode_位运算_简单_405.数字转换为十六进制数
- How do we do full-link grayscale on the database?
- 【每日一题】1331. 数组序号转换
- shell 中的 分发系统 expect脚本 (传递参数、自动同步文件、指定host和要传输的文件、(构建文件分发系统)(命令批量执行))
猜你喜欢

JMP Pro 16.0 software installation package download and installation tutorial

芝加哥丰田技术学院 | Leveraging Natural Supervision for Language Representation Learning and Generation(利用自然监督进行语言表示学习和生成)

【2022蓝帽杯】file_session && 浅入opcode

快速理解拉格朗日乘子法

PyTorch 进阶之路:在 GPU 上训练深度神经网络
![leetcode: 1201. Ugly Number III [Dichotomy + Mathematics + Inclusion and Exclusion Principle]](/img/44/bf1d9b9d85939e73bc44be2f9701e1.png)
leetcode: 1201. Ugly Number III [Dichotomy + Mathematics + Inclusion and Exclusion Principle]

MySQL调优

shell 中的 分发系统 expect脚本 (传递参数、自动同步文件、指定host和要传输的文件、(构建文件分发系统)(命令批量执行))

【每日一题】1331. 数组序号转换

PAT 1163 Dijkstra Sequence(30)
随机推荐
What is consistent hashing?In what scenarios can it be applied?
快速理解拉格朗日乘子法
50W+小程序开发者背后的数据库降本增效实践
【每日一题】1331. 数组序号转换
一文带你彻底厘清 Isito 中的证书工作机制
数据挖掘-03
VIP的实现原理
Qt实战案例(55)——利用QDir删除选定文件目录下的空文件夹
测试发文
Simulation implementation of new of Js handwritten function
iframe tag attribute description detailed [easy to understand]
The obstacles to put Istio into production and how we solve them
人像分割技术解析与应用
让程序员早点下班的效率工具
34、树莓派进行人体姿态检测并进行语音播报
使用ffmpeg来查看视频的信息,fps,和width,height
Programmer's Romantic Tanabata
软件测试之发现和解决bug
AtCoder Beginner Contest 261 D - Flipping and Bonus
【StoneDB Class】Introduction Lesson 2: Analysis of the Overall Architecture of StoneDB