当前位置:网站首页>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: Contributing
- Common faults of MySQL database - forgetting database password
- Summary of wechat applet test points
- Basic methods for network diagnosis and hardware troubleshooting of Beifu EtherCAT module
- Log in to the server using SSH key pair
- 享元模式(Flyweight)
- scrapy——爬取漫画自定义存储路径下载到本地
- 首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
- Mode pont
- Processsing mouse interactive learning
猜你喜欢
Fire warning is completed within 10 seconds, and Baidu AI Cloud helps Kunming Guandu build a new benchmark of smart city
Design of simple digital circuit traffic light
原型模式(prototype)
Opencv high speed download
Enjoy element mode (flyweight)
Mysql database explanation (III)
Beifu twincat3 can read and write CSV and txt files
Bigint: handles large numbers (integers of any length)
MySQL explanation (II)
10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
随机推荐
2、并行接口、协议和相关芯片介绍(8080、8060)
B - Bridging signals
Electron official docs series: Processes in Electron
组合模式(Composite )
Uva5009 error curves three points
Update and download of Beifu EtherCAT XML description file
D - skiing
5月产品升级观察站
code force Party Lemonade
C - Common Subsequence
C language: Exercise 2
Decorator
Beifu PLC based on NT_ Shutdown to realize automatic shutdown and restart of controller
HDU 3555 Bomb
Sinotech software outsourcing
D - 滑雪
享元模式(Flyweight)
MySQL explanation (II)
Beifu PLC realizes data power-off maintenance based on cx5130
What features are added to Photoshop 2022 23.4.1? Do you know anything