这道题目的解题思路是动态规划,通过N和K进行状态转移
#include <cstdio>
#include <cmath>
int a[40][900];
int n,k;
void work(){
a[1][1]=1;
for(int i=2;i<=n;i++){
for(int j=0;j<=(i+1)*i/2;j++){
a[i][j]=0;
if((i+j)<=(i-1)*i/2){
a[i][j]+=a[i-1][i+j];
}
if(j!=0){
if(i>=j)
a[i][j]+=a[i-1][i-j];
if(i<=j)
a[i][j]+=a[i-1][j-i];
}
// printf("%d %d %d\n",i,j,a[i][j]);
}
}
}
int main(){
scanf("%d%d",&n,&k);
if(k>(n+1)*n/2){
printf("0\n");
}else{
work();
printf("%d\n",a[n][k]);
}
return 0;
}
分享到:
相关推荐
校准Feedback Control of Dynamic Systems(7th Edition)[Gene F. Franklin]
JEDEC JESD88F:2018 JEDEC Dictionary of Terms for Solid-State Technology – 7th Edition - 完整英文电子版(276页).pdf
Title: C++ Programming: From Problem Analysis to Program Design, 7th Edition Author: D. S. Malik Length: 1488 pages Edition: 7 Language: English Publisher: Course Technology Publication Date: 2014-02-...
Feedback Control of Dynamic Systems 第六版 + 第七版 都是文字版,清晰,方便做标注
Computer Networking 作者: James F. Kurose / Keith W. Ross 出版社: Pearson 副标题: A Top-Down Approach 出版年: 2012-3-5 页数: 864 定价: USD 171.60 装帧: Hardcover ISBN: 9780132856201
JEDEC JESD88F:2018 JEDEC Dictionary of Terms for Solid-State Technology – 7th Edition - 完整英文电子版(276页).zip
数据库系统概念答案,英文版,原书Abraham Silberschatz, Henry F.Korth, S.Sudarshan编著版本
Bonn, Institut für Anorganische Chemie der Universität Received March 7th, 2002. Dedicated to Professor Rudolf Hoppe on the Occasion of his 80th Birthday Abstract. The reaction of Se4[Mo2O2Cl8] ...
Bonn, Institut für Anorganische Chemie der Universität Received March 7th, 2002. Dedicated to Professor Rudolf Hoppe on the Occasion of his 80th Birthday Abstract. The reaction of Se4[Mo2O2Cl8] ...
Solvolysis Products of the Types [RhMeL2(Me3[9]aneN3)]2+ and [RuCl3-XLX(Me3[9]...Bochum, Lehrstuhl für Analytische Chemie der Ruhr-Universität Bochum Received February 7th, 2002 Abstract. Solvolysi
Solvolysis Products of the Types [RhMeL2(Me3[9]aneN3)]2+ and [RuCl3-XLX(Me3[9]...Bochum, Lehrstuhl für Analytische Chemie der Ruhr-Universität Bochum Received February 7th, 2002 Abstract. Solvolysi
John F. Buford, Avaya Labs, USA Moushumi Sharmin, Marquette University, USA Munirul M. Haque, Marquette University, USA Nilothpal Talukder, Marquette University, USA Chapter III Security of Mobile...
F: Fighting Spam For Dummies.chm Firefox For Dummies.chm Firewalls For Dummies 2nd Ed.pdf Flash CS3 For Dummies May 2007.pdf ** Food Allergies For Dummies.pdf For Dummies Flash CS3 For Dummies May ...
* fixed: downconverting WAV files with 0x3f channel mask didn't work * fixed: log output "remaining delay [...]" was sometimes wrong for AC3 tracks * fixed: silent frame creation was tried for E-AC3 ...