当前位置:网站首页>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;
}
边栏推荐
- 程序员的浪漫七夕
- 意大利普拉托华社将游行示威 盼解决安全问题
- 通讯录(静态版)(C语言)(VS)
- kubernetes之DaemonSet以及滚动更新
- 一文带你彻底厘清 Isito 中的证书工作机制
- 28uA待机8米距离低压保护单片机探头太阳能灯人体PIR定制方案
- sql中常用到的正则表达
- 数字孪生北京故宫,元宇宙推进旅游业进程
- Six Stones Programming: Problems must be faced, methods must be skillful, and functions that cannot be done well must be solved
- 响应式2022英文企业官网源码,感觉挺有创意的
猜你喜欢
脚本语言Lua的基础知识总结
四足机器人软件架构现状分析
leetcode: 1201. Ugly Number III [Dichotomy + Mathematics + Inclusion and Exclusion Principle]
NebulaGraph v3.2.0 性能报告
响应式2022英文企业官网源码,感觉挺有创意的
Batch replace tables in Word with pictures and save
关于Request复用的那点破事儿。研究明白了,给你汇报一下。
Based on 10 years of experience in stability assurance, what are the three key questions to be answered in failure recovery?|TakinTalks big coffee sharing
SAP ABAP OData 服务如何支持创建(Create)操作试读版
Feign 从注册到调用原理分析
随机推荐
库函数的模拟实现(strlen)(strcpy)(strcat)(strcmp)(strstr)(memcpy)(memmove)(C语言)(VS)
SAP ABAP OData 服务如何支持创建(Create)操作试读版
kubernetes之DaemonSet以及滚动更新
数字孪生北京故宫,元宇宙推进旅游业进程
程序员的浪漫七夕
六石编程学:问题要面对,办法要技巧,做不好的功能要想办法
AI目标分割能力,无需绿幕即可实现快速视频抠图
如何将第三方服务中心注册集成到 Istio ?
Feign 从注册到调用原理分析
华盛顿大学、Allen AI 等联合 | RealTime QA: What's the Answer Right Now?(实时 QA:现在的答案是什么?)
免费使用高性能的GPU和TPU—谷歌Colab使用教程
fh511小风扇主控芯片 便携式小风扇专用8脚IC 三档小风扇升压芯片sop8
模型运营是做什么的(概念模型数据库)
The basic knowledge of scripting language Lua summary
让程序员早点下班的效率工具
What Can Service Mesh Learn from SDN?
NFV迈向云原生时代:Network Service Mesh项目介绍
formatdatetime函数 mysql(date sub函数)
使用ffmpeg来查看视频的信息,fps,和width,height
PanGu-Coder:函数级的代码生成模型