当前位置:网站首页>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 
边栏推荐
- 哈希表 AcWing 840. 模拟散列表
- Docker compose configuration mysql, redis, mongodb
- Heap acwing 838 Heap sort
- std::vector批量导入快速去重方法
- Go learning notes - multithreading
- Embedded Software Engineer career planning
- [I'm a mound pytorch tutorial] learning notes
- Performance tuning project case
- 堆 AcWing 838. 堆排序
- Redis sentinel mechanism and configuration
猜你喜欢

模块化 CommonJS ES Module

Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)

High performance erasure code coding

Simple use of drools decision table

线性DP AcWing 896. 最长上升子序列 II

What is the relationship between NFT and metauniverse? How to view the market? The future market trend of NFT

BOM DOM

Redis sentinel mechanism and configuration

Programmers can't find jobs after the age of 35? After reading this article, you may be able to find the answer
![JDBC prevent SQL injection problems and solutions [preparedstatement]](/img/32/f71f5a31cdf710704267ff100b85d7.png)
JDBC prevent SQL injection problems and solutions [preparedstatement]
随机推荐
[ybtoj advanced training guidance] cross the river [BFS]
Redis sentinel mechanism and configuration
"As a junior college student, I found out how difficult it is to counter attack after graduation."
How to write a pleasing English mathematical paper
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
Window10 upgrade encountered a big hole error code: 0xc000000e perfect solution
传感器 ADXL335BCPZ-RL7 3轴 加速度计 符合 RoHS/WEEE
js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)
JS6day(DOM结点的查找、增加、删除。实例化时间,时间戳,时间戳的案例,重绘和回流)
哈希表 AcWing 840. 模拟散列表
线性DP AcWing 902. 最短编辑距离
通过反射执行任意类的任意方法
Hash table acwing 840 Simulated hash table
spfa AcWing 851. SPFA finding the shortest path
Redis bloom filter
染色法判定二分图 AcWing 860. 染色法判定二分图
接口测试面试题目,你都会了吗?
There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes
[FFH] little bear driver calling process (take calling LED light driver as an example)