当前位置:网站首页>7-16 monetary system I
7-16 monetary system I
2022-06-26 13:21:00 【White -】
7-16 The monetary system Ⅰ
To give you one n A monetary system of denominations , Find the face value of the composition as m How many currencies are there .
Input format
first line , Contains two integers n and m.
Next n That's ok , Each line contains an integer , Represents the face value of a currency .
Output format
All in one line , Contains an integer , Number of solutions .
Data range
n≤15,m≤3000
sample input :
3 10
1
2
5
sample output :
10
Code :
#include<stdio.h>
int n,m;
int a[20];
int sum=0;
int vis[20][100000];
int find(int x,int money)
{
if(money==m)
{
sum++;
return 0;
}
if(money>m)
return 0;
if(x>=n)
return 0;
if(vis[x][money]!=0)
return vis[x][money];
int len=(m-money)/a[x];
for(int i=len;i>=0;i--)
vis[x][money]=find(x+1,money+a[x]*i)+a[x]*i;
}
int main()
{
while( scanf("%d%d",&n,&m)!=EOF)
{
memset(a,0,sizeof(a));
memset(vis,0,sizeof(vis));
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
find(0,0);
printf("%d\n",sum);
sum=0;
}
}
202206260906 Japan
边栏推荐
- Electron official docs series: Get Started
- 5月产品升级观察站
- A few lines of code can realize complex excel import and export. This tool class is really powerful!
- ES6 module
- MySQL数据库常见故障——遗忘数据库密码
- Dark horse notes - Common APIs
- Summary of wechat applet test points
- 12 SQL optimization schemes summarized by old drivers (very practical)
- Log in to the server using SSH key pair
- Hdu1724[Simpson formula for integral]ellipse
猜你喜欢

Learn how to develop owl components by hand (7): practical use of owl projects

What features are added to Photoshop 2022 23.4.1? Do you know anything

橋接模式(Bridge)
![Hdu1724[Simpson formula for integral]ellipse](/img/57/fb5098e150b5f3d91a5d0983a336ee.png)
Hdu1724[Simpson formula for integral]ellipse

MariaDB study notes

Oplg: new generation cloud native observable best practices

awk工具

Arcpy——InsertLayer()函數的使用:摻入圖層到地圖文檔裏
What should the software test report include? Interview must ask

12 SQL optimization schemes summarized by old drivers (very practical)
随机推荐
[how to connect the network] Chapter 2 (Part 1): establish a connection, transmit data, and disconnect
A few lines of code can realize complex excel import and export. This tool class is really powerful!
C - Common Subsequence
Mode pont
MySQL explanation (II)
Some conclusions about Nan
Composite mode
H5视频自动播放和循环播放
利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
[how to connect the network] Chapter 2 (middle): sending a network packet
Nlp-d60-nlp competition D29
Beifu PLC obtains system time, local time, current time zone and system time zone conversion through program
原型模式(prototype)
Explain C language 10 in detail (C language series)
MySQL数据库讲解(四)
Bifu divides EtherCAT module into multiple synchronization units for operation -- use of sync units
E - Apple Catching
SQL assigns the field value of data table B to a column in data table a
Dark horse notes - Common APIs
UVa11582 [快速幂]Colossal Fibonacci Numbers!