当前位置:网站首页>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 marketing of consumer goods enterprises in the future
- [graduation season · advanced technology Er] I remember the year after graduation
- UDP protocol details [easy to understand]
- Investment forecast and development strategy analysis report of China's rural sewage treatment industry in 2022
- redis通过6379端口无法连接服务器
- Quantitative elementary -- akshare obtains stock code, the simplest strategy
- Mysql8 master-slave replication
- One click deployment of your own community forum
- 十大券商有哪些?手机开户安全么?
- PHP laravel+gatewayworker completes im instant messaging and file transfer functions (Chapter 2: explanation of business logic)
猜你喜欢

PHP laravel+gatewayworker completes im instant messaging and file transfer (Chapter 1: basic configuration)

ctfshow web入门 命令执行web75-77

HUST网络攻防实践|6_物联网设备固件安全实验|实验二 基于 MPU 的物联网设备攻击缓解技术

Xiaolong 888 was released, Xiaomi 11 was launched, and 14 manufacturers carried it in the first batch!

4. N queen problem

Jmeter响应时间和tps监听器使用教程

Ctfshow web getting started command execution web75-77

Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)

dried food! Yiwen will show you SD card, TF card and SIM card!
![[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]](/img/13/c2c63333a9e5ac08b339449ea17654.jpg)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
随机推荐
Analysis report on China's photovoltaic inverter market prospect forecast and investment strategy recommendations in 2022
What are the top ten securities companies? Is it safe to open a mobile account?
webgame开发中的文件解密
JMeter response time and TPS listener tutorial
Scala-day02- variables and data types
Laravel uses find_ IN_ The set() native MySQL statement accurately queries whether a special string exists in the specified string to solve the problem that like cannot be accurately matched. (resolve
Example of parameter passing from laravel query constructor to closure method
NFS shared storage service installation
HUST网络攻防实践|6_物联网设备固件安全实验|实验二 基于 MPU 的物联网设备攻击缓解技术
What software is flush? Is online account opening safe?
HUST network attack and defense practice | 6_ IOT device firmware security experiment | Experiment 3 freertos-mpu protection bypass
How to do well in member marketing three steps to teach you to understand member management
Prospering customs through science and technology, Ronglian and Tianjin Customs jointly build a genomic database and analysis platform
The loss of female scientists
One click deployment CEPH script
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
PHP get directory size
Deep thinking from senior member managers
1、 MySQL introduction
leetcode 715. Range 模块 (hard)