当前位置:网站首页>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;
}
边栏推荐
- 【StoneDB Class】入门第二课:StoneDB 整体架构解析
- leetcode:1201. 丑数 III【二分 + 数学 + 容斥原理】
- How to integrate 3rd party service center registration into Istio?
- Why does the maximum plus one equal the minimum
- NFV迈向云原生时代:Network Service Mesh项目介绍
- 使用open3d可视化3d人脸
- 力扣160题,相交链表
- 易优压双驱挖掘机压路机器类网站源码 v1.5.8
- AD单片机九齐单片机NY8B062D SOP16九齐
- 关于Request复用的那点破事儿。研究明白了,给你汇报一下。
猜你喜欢

华盛顿大学、Allen AI 等联合 | RealTime QA: What's the Answer Right Now?(实时 QA:现在的答案是什么?)

PanGu-Coder:函数级的代码生成模型

Multi-threaded cases - blocking queue

34、树莓派进行人体姿态检测并进行语音播报

Towhee 每周模型

MySQL调优

leetcode:1201. 丑数 III【二分 + 数学 + 容斥原理】

Efficiency tools to let programmers get off work earlier

NebulaGraph v3.2.0 性能报告

易优压双驱挖掘机压路机器类网站源码 v1.5.8
随机推荐
Six Stones Programming: Problems must be faced, methods must be skillful, and functions that cannot be done well must be solved
如何降低Istio服务网格中Envoy的内存开销
【5GC】5G网络切片与5G QoS的区别?
批量任务导入到数据库中
2022-07-29 网工进阶(二十二)BGP-其他特性(路由过滤、团体属性、认证、AS欺骗、对等体组、子路由器、路由最大接收数量)
响应式2022英文企业官网源码,感觉挺有创意的
AtCoder Beginner Contest 261 D - Flipping and Bonus
【码蹄集新手村600题】判断一个数字是否为完全平方数
制售假劣农资、非法占用耕地……公安部公布十起危害粮食生产安全犯罪典型案例
tensorflow2.0 handwritten digit recognition (tensorflow handwriting recognition)
Why does the maximum plus one equal the minimum
预防和制止家庭暴力 人身安全保护令司法解释今起施行
让程序员早点下班的效率工具
珠海首个水环境安全监测系统上线
10年稳定性保障经验总结,故障复盘要回答哪三大关键问题?|TakinTalks大咖分享
postgresql之page分配管理(二)
数字证书原理
Multithreading Case - Timer
芝加哥丰田技术学院 | Leveraging Natural Supervision for Language Representation Learning and Generation(利用自然监督进行语言表示学习和生成)
PanGu-Coder:函数级的代码生成模型