当前位置:网站首页>Write some DP
Write some DP
2022-07-29 07:33:00 【A little Yu】
Title Description
When Zhenzhen learns multiplication , Find out 4=2*2,9=3*3,…, and 2 It is impossible to decompose into the product of two identical integers , But it can be broken down into 1*1+1*1. She wants to know for any positive integer n, Divide it into several integers and multiply it by itself , How many options are there ?
Input
There is only one line of input , This line has only one positive integer n.
Output
There is only one line of output , This line has only one positive integer , Represents the total number of schemes .
The sample input Copy
13Sample output Copy
6Tips
30% The data of ,1≤n≤10;
80% The data of ,1≤n≤300;
100% The data of ,1≤n≤800.
A two-dimensional dp
#include <bits/stdc++.h>
using namespace std;
int n,i,j;
int k;
int a[35];
int dp[905][905];
void solve()
{
dp[0][0]=1;
for(i=1;i<=30;i++)
{
for(j=0;j<=k;j++)
{
for(int t=0;t*a[i]<=j;t++)
{
dp[i][j]+=dp[i-1][j-t*a[i]];
}
}
}
printf("%d",dp[30][k]);
}
int main()
{
cin>>k;
for(i=1;i<=30;i++)
{
a[i]=i*i;
}
solve();
return 0;
}A one-dimensional dp
#include <bits/stdc++.h>
using namespace std;
int n,i,j;
int k;
int a[35];
int dp[905];
void solve()
{
dp[0]=1;
for(i=1; i<=30; i++)
{
for(j=k;j>=0;j--)// Write it right upside down , It's written incorrectly
{
for(int t=1; t*a[i]<=j; t++)
{
dp[j]+=dp[j-t*a[i]];
}
}
}
printf("%d",dp[k]);
}
int main()
{
cin>>k;
for(i=1; i<=30; i++)
{
a[i]=i*i;
}
solve();
return 0;
}
边栏推荐
- Pat class a 1154 vertex shading
- Introduction to logback appender
- QT topic: basic components (button class, layout class, output class, input class, container class)
- log4qt内存泄露问题,heob内存检测工具的使用
- [summer daily question] Luogu p4413 [coci2006-2007 2] R2
- 分析25个主要DeFi协议的路线图 预见DeFi未来的七大趋势
- 【暑期每日一题】洛谷 P6320 [COCI2006-2007#4] SIBICE
- Halcon installation and testing in vs2017, DLL configuration in vs2017
- mysql 单表最多能存多少数据?
- Reflect reflect
猜你喜欢

2022年深圳杯A题破除“尖叫效应”与“回声室效应”走出“信息茧房”

Prometheus与Grafana

国内数字藏品的乱象与未来

Meizhi optoelectronics' IPO was terminated: annual revenue of 926million he Xiangjian was the actual controller

Use of gcc/g++

Getting started with JDBC

女研究生做“思维导图”与男友吵架!网友:吵架届的“内卷之王”....

零数科技深度参与信通院隐私计算金融场景标准制定

Some learning and understanding of vintage analysis

梳理市面上的2大NFT定价范式和4种解决方案
随机推荐
gin abort不能阻止后续代码的问题
状态机dp(简单版)
MySQL如何把行转换为列?
How can electronic component trading enterprises solve warehouse management problems with ERP system?
5-整合swagger2
JS day 4 process control (if statement and switch statement)
【暑期每日一题】洛谷 P4413 [COCI2006-2007#2] R2
log4j Layout简介说明
MapReduce各阶段步骤
Synchronous / asynchronous, blocking / non blocking and IO
OA项目之会议通知(查询&是否参会&反馈详情)
受欢迎的牛 G
Levelfilter introduction
[daily question in summer] Luogu p6408 [coci2008-2009 3] pet
新生代公链再攻「不可能三角」
QT basic day 2 (2) QT basic components: button class, layout class, output class, input class, container and other individual examples
[summer daily question] Luogu P6500 [coci2010-2011 3] zbroj
[MySQL] - [subquery]
QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)
Pat class a 1154 vertex shading