当前位置:网站首页>7-16 货币系统Ⅰ
7-16 货币系统Ⅰ
2022-06-26 12:32:00 【白—】
7-16 货币系统Ⅰ
给你一个n种面值的货币系统,求组成面值为m的货币有多少种方案。
输入格式
第一行,包含两个整数n和m。
接下来n行,每行包含一个整数,表示一种货币的面值。
输出格式
共一行,包含一个整数,表示方案数。
数据范围
n≤15,m≤3000
输入样例:
3 10
1
2
5
输出样例:
10
代码:
#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日
边栏推荐
- Five trends of member management in 2022
- Omni channel member link - tmall member link 3: preparation of member operation content
- Build document editor based on slate
- Black squares in word
- [solved] data duplication or data loss after laravel paginate() paging
- Prospering customs through science and technology, Ronglian and Tianjin Customs jointly build a genomic database and analysis platform
- 2022 edition of China's energy and chemical industry market in-depth investigation and investment feasibility analysis report
- PolarisMesh系列文章——概念系列(一)
- Omnichannel membership - tmall membership 2: frequently asked questions
- New routing file in laravel framework
猜你喜欢

4. N queen problem

Laravel+gatewayworker completes the im instant messaging and file transfer functions (Chapter 4: server debugging errors)

Realize microservice load balancing (ribbon)

Statistical genetics: Chapter 2, the concept of statistical analysis

HUST network attack and defense practice | 6_ IOT device firmware security experiment | Experiment 3 freertos-mpu protection bypass

Spark-day02-core programming-rdd

2、 MySQL Foundation
![[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure](/img/d2/a6cbb0abe9e04c412d1f6021430528.png)
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure

MySQL optimization - index (what is an index?)

Php+laravel5.7 use Alibaba oss+ Alibaba media to process and upload image / video files
随机推荐
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
The most complete kubernetes core command of the latest version so far
1、 MySQL introduction
How to do well in member marketing three steps to teach you to understand member management
女性科学家的流失
Polarismesh series articles - concept series (I)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
Mqtt disconnect and reconnect
Rookie practical UML - activity diagram
Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open a mobile account?
Which is safer and better for great wisdom to open an account
Mysql8 master-slave replication
UDP协议详解[通俗易懂]
How do consumer goods enterprises formulate membership interests?
Oracle锁表查询和解锁方法
The transformation of enterprise customers' digital assets needs to suit the case
Five strategies and suggestions of member marketing in consumer goods industry
"Pinduoduo and short video speed version", how can I roast!
2022 edition of China's cotton chemical fiber printing and dyeing Market Status Investigation and Prospect Forecast Analysis Report
2022 China smart bathroom cabinet Market Research and investment Competitiveness Analysis Report