当前位置:网站首页>Counting class DP acwing 900 Integer partition
Counting class DP acwing 900 Integer partition
2022-07-02 12:43:00 【T_ Y_ F666】
Count class DP AcWing 900. Integer partition
Original link
Algorithm tags
Dynamic programming Count class DP
Ideas
Code
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>b;--i)
using namespace std;
const int N = 1005, INF = 0x3f3f3f3f, mod = 1e9+7;
int n;
int f[N];
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n=read();
// f[1] = 1 And f[1] = f[1] + f[0], therefore f[0] = 1
// It can also be understood that only in the past 0 Select the number and sum as 0 The number of schemes is 1, Because not choosing can satisfy and serve 0, It's also a plan
f[0]=1;
// For the first i Number
rep(i, 1, n+1){
// Residual capacity
rep(j, i, n+1){
f[j]=(f[j]+f[j-i])%mod;
}
}
printf("%lld", f[n]);
return 0;
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support
边栏推荐
- About wechat enterprise payment to change x509certificate2 read certificate information, publish to the server can not access the solution
- Intel internal instructions - AVX and avx2 learning notes
- CV2 in OpenCV VideoWriter_ Fourcc() function and cv2 Combined use of videowriter() function
- Distributed machine learning framework and high-dimensional real-time recommendation system
- Go learning notes - multithreading
- Drools dynamically add, modify, and delete rules
- 线性DP AcWing 896. 最长上升子序列 II
- Sparkcontext: error initializing sparkcontext solution
- Visual studio efficient and practical extension tools and plug-ins
- js1day(输入输出语法,数据类型,数据类型转换,var和let区别)
猜你喜欢
Dijkstra AcWing 850. Dijkstra finding the shortest circuit II
3 A VTT端接 稳压器 NCP51200MNTXG资料
分布式机器学习框架与高维实时推荐系统
防抖 节流
Js6day (search, add and delete DOM nodes. Instantiation time, timestamp, timestamp cases, redrawing and reflow)
BOM DOM
This "little routine" is set on the dough cake of instant noodles. No wonder programmers are always hungry
Drools dynamically add, modify, and delete rules
Sweetheart leader: Wang Xinling
Docker compose configuration mysql, redis, mongodb
随机推荐
About the loading of layer web spring layer components, the position of the layer is centered
Error in kubeadm join: [error port-10250]: port 10250 is in use [error fileavailable--etc kubernetes PKI
线性DP AcWing 896. 最长上升子序列 II
Direct control PTZ PTZ PTZ PTZ camera debugging (c)
线性DP AcWing 902. 最短编辑距离
Drools dynamically add, modify, and delete rules
spfa AcWing 851. spfa求最短路
The differences and relationships among port, targetport, nodeport and containerport in kubenetes
线性DP AcWing 899. 编辑距离
Shutter encapsulated button
百款拿来就能用的网页特效,不来看看吗?
How to write a pleasing English mathematical paper
高性能纠删码编码
防抖 节流
堆 AcWing 838. 堆排序
async/await 异步函数
js1day(输入输出语法,数据类型,数据类型转换,var和let区别)
Rust search server, rust quick service finding tutorial
哈希表 AcWing 841. 字符串哈希
Execute any method of any class through reflection