当前位置:网站首页>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
边栏推荐
- 利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
- C language: Exercise 2
- Arcpy -- use of insertlayer() function: adding layers to map documents
- Script - crawl the customized storage path of the cartoon and download it to the local
- 2、并行接口、协议和相关芯片介绍(8080、8060)
- Bigint: handles large numbers (integers of any length)
- MySQL数据库讲解(五)
- LeetCode_ Stack_ Medium_ 150. evaluation of inverse Polish expression
- POJ 3070 Fibonacci
- HDU 3709 Balanced Number
猜你喜欢

Adapter mode

Beifu PLC obtains system time, local time, current time zone and system time zone conversion through program

shell脚本详细介绍(四)

Arcpy——InsertLayer()函数的使用:掺入图层到地图文档里

Processing random generation line animation

ES6:Map

Explain C language 10 in detail (C language series)

Fire warning is completed within 10 seconds, and Baidu AI Cloud helps Kunming Guandu build a new benchmark of smart city

Enjoy element mode (flyweight)

2. Introduction to parallel interface, protocol and related chips (8080, 8060)
随机推荐
HDU 5860
Mysql database explanation (III)
MySQL讲解(二)
解中小企业之困,百度智能云打个样
Learn how to develop owl components by hand (7): practical use of owl projects
Electron official docs series: Processes in Electron
橋接模式(Bridge)
C - Common Subsequence
Nlp-d60-nlp competition D29
Beifu PLC based on NT_ Shutdown to realize automatic shutdown and restart of controller
LeetCode_ Stack_ Medium_ 150. evaluation of inverse Polish expression
Common creation and usage of singletons
What are the common categories of software testing?
装饰器(Decorator)
Electron official docs series: Testing And Debugging
Mysql database explanation (V)
Custom encapsulation drop-down component
Reflect the technical depth (unable to speed up)
Decorator
Common faults of MySQL database - forgetting database password