当前位置:网站首页>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 
边栏推荐
- Some sudden program ideas (modular processing)
- Leetcode - Sword finger offer 37, 38
- Adding database driver to sqoop of cdh6
- China traffic sign detection data set
- Js10day (API phased completion, regular expression introduction, custom attributes, filtering sensitive word cases, registration module verification cases)
- 线性DP AcWing 899. 编辑距离
- Performance tuning project case
- [ybtoj advanced training guide] similar string [string] [simulation]
- [ybtoj advanced training guidance] judgment overflow [error]
- LTC3307AHV 符合EMI标准,降压转换器 QCA7005-AL33 PHY
猜你喜欢

bellman-ford AcWing 853. 有边数限制的最短路

The differences and relationships among port, targetport, nodeport and containerport in kubenetes

应用LNK306GN-TL 转换器、非隔离电源

Deep copy event bus

Deep Copy Event bus

This "little routine" is set on the dough cake of instant noodles. No wonder programmers are always hungry

The programmer and the female nurse went on a blind date and spent 360. He packed leftovers and was stunned when he received wechat at night

bellman-ford AcWing 853. Shortest path with side limit

哈希表 AcWing 840. 模拟散列表

BOM DOM
随机推荐
"As a junior college student, I found out how difficult it is to counter attack after graduation."
哈希表 AcWing 841. 字符串哈希
Mongodb redis differences
Deep Copy Event bus
Does C language srand need to reseed? Should srand be placed in the loop? Pseudo random function Rand
高性能纠删码编码
线性DP AcWing 896. 最长上升子序列 II
深拷贝 事件总线
Redis transaction mechanism implementation process and principle, and use transaction mechanism to prevent inventory oversold
Use MySQL events to regularly perform post seven world line tasks
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
Go learning notes - go based interprocess communication
FBX import under ue4/ue5 runtime
堆 AcWing 838. 堆排序
堆 AcWing 839. 模拟堆
AI mid stage technology research
正确遍历EntryList方法
async/await 异步函数
Writing method of then part in drools
Enhance network security of kubernetes with cilium