博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[HAOI????] 硬币购物
阅读量:4557 次
发布时间:2019-06-08

本文共 775 字,大约阅读时间需要 2 分钟。

 硬币购物

 
题目描述 Description

一共有4种硬币。面值分别为c1,c2,c3,c4。某人去商店买东西,去了tot次。 每次带di枚ci硬币,买si的价值的东西。请问每次有多少种付款方法。

输入描述 Input Description

第一行 c1,c2,c3,c4,tot 下面tot行 d1,d2,d3,d4,s

输出描述 Output Description

每次的方法数

样例输入 Sample Input

1 2 5 10 2

3 2 3 1 10
1000 2 2 2 900

样例输出 Sample Output

4

27

数据范围及提示 Data Size & Hint

di,s<=100000
tot<=1000

 

背包+容斥即可。

 

#include
#define ll long long#define maxn 100005using namespace std;ll f[maxn],ans;int a[10],ci[20],T,S;int n,m,tmp[105],tot[105];inline void dp(){ f[0]=1; for(int i=0;i<4;i++) for(int j=a[i];j<=100000;j++) f[j]+=f[j-a[i]]; tmp[0]=1; for(int i=1;i
=tot[i]) ans+=tmp[i]*f[S-tot[i]]; } printf("%lld\n",ans); } return 0;}

  

 

转载于:https://www.cnblogs.com/JYYHH/p/8540159.html

你可能感兴趣的文章
bzoj2067: [Poi2004]SZN
查看>>
所谓独立环境
查看>>
当代GSM手机的硬件系统分析[zz]
查看>>
对我影响最深的三个老师
查看>>
开源项目托管GitHub
查看>>
Unity学习笔记—— 常用脚本函数
查看>>
.getCellType()的几种类型值
查看>>
linux中启动 java -jar 后台运行程序
查看>>
运行web项目端口占用问题
查看>>
Java Spring-IOC和DI
查看>>
【NOIP1999】【Luogu1015】回文数(高精度,模拟)
查看>>
Linux上安装Python3.5
查看>>
crt安装
查看>>
git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git
查看>>
c++中static的用法详解
查看>>
转 我修改的注册表,但是程序运行起来,还是记着以前的
查看>>
图片轮播功能
查看>>
第六周小组作业:软件测试和评估
查看>>
linux Cacti监控服务器搭建
查看>>
debian(kali Linux) 安装net Core
查看>>