当前位置:网站首页>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;
}
边栏推荐
- 四足机器人软件架构现状分析
- 【每日一题】952. 按公因数计算最大组件大小
- 一文带你彻底厘清 Isito 中的证书工作机制
- 【StoneDB Class】入门第二课:StoneDB 整体架构解析
- 如何使用OpenCV测量图像中物体之间的距离
- 【每日一题】593. 有效的正方形
- Windows 安装PostgreSQL
- 预防和制止家庭暴力 人身安全保护令司法解释今起施行
- Software designer test center summary (interior designer personal summary)
- Grafana 9.0 released, Prometheus and Loki query builders, new navigation, heatmap panels and more!
猜你喜欢
随机推荐
tensorflow2.0手写数字识别(tensorflow手写体识别)
markdown常用数学符号cov(markdown求和符号)
Why does the maximum plus one equal the minimum
SQL函数 %SQLSTRING
软件测试之发现和解决bug
论文详读《基于改进 LeNet-5 模型的手写体中文识别》,未完待补充
iframe tag attribute description detailed [easy to understand]
【StoneDB Class】Introduction Lesson 2: Analysis of the Overall Architecture of StoneDB
响应式2022英文企业官网源码,感觉挺有创意的
安全又省钱,“15岁”老小区用上管道燃气
PanGu-Coder:函数级的代码生成模型
8. How does the SAP ABAP OData service support the Create operation
多线程案例——定时器
PAT 1163 Dijkstra Sequence(30)
【2022蓝帽杯】file_session && 浅入opcode
AI目标分割能力,无需绿幕即可实现快速视频抠图
Data Mining-04
MySQL调优
DDL和DML的含义与区别「建议收藏」
Feign 从注册到调用原理分析









