当前位置:网站首页>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: References
- Mysql database explanation (6)
- UVA5009 Error Curves三分
- Beifu PLC based on NT_ Shutdown to realize automatic shutdown and restart of controller
- Es6: iterator
- Custom encapsulation drop-down component
- 5月产品升级观察站
- IDC报告:百度智能云AI Cloud市场份额连续六次第一
- G - Cow Bowling
- 10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
猜你喜欢

Processsing mouse interactive learning

防火墙介绍

Beifu PLC realizes zero point power-off hold of absolute value encoder -- use of bias

Processing function translate (mousex, mousey) learning

Arcpy - - utilisation de la fonction insertlayer (): ajout de calques dans un document de carte

Arcpy——InsertLayer()函數的使用:摻入圖層到地圖文檔裏

Script - crawl the customized storage path of the cartoon and download it to the local
What should the software test report include? Interview must ask

Arcpy -- use of insertlayer() function: adding layers to map documents

Echart stack histogram: add white spacing effect setting between color blocks
随机推荐
Composite mode
Design of four kinds of linear phase FIR filters -- complete set of Matlab source code
MySQL数据库常见故障——遗忘数据库密码
Mysql database explanation (V)
Es6: iterator
Beifu PLC based on NT_ Shutdown to realize automatic shutdown and restart of controller
J - Wooden Sticks poj 1065
I - Dollar Dayz
Mysql database explanation (6)
Bridge mode
Generate JDE dot train
Design of simple digital circuit traffic light
适配器模式(Adapter)
sed编辑器
Update and download of Beifu EtherCAT XML description file
H5视频自动播放和循环播放
MySQL讲解(二)
H5 video automatic playback and circular playback
To solve the difficulties of small and medium-sized enterprises, Baidu AI Cloud makes an example
C - Common Subsequence