JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

D - Money in Hand

发布时间 2023-12-28 11:47:34作者: yufan1102

image
image

有点像完全背包,但也不是因为有数量的限制,是01背包的变式,每个硬币选与不选,最后看看能不能达到x。

#include<bits/stdc++.h>
using namespace std;
int t[100],w[100],dp[10005];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>t[i];
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=t[i];j++){
			for(int k=m;k>=w[i];k--){
				if(dp[k-w[i]])dp[k]=1;
			}
		} 
	}
	if(dp[m]){
		cout<<"Yes";
	}else{
		cout<<"No"; 
	}
}
    本栏目推荐文章
  • vscode错误:Unable to connect to VS Code server: Error in request.
  • 【五期李伟平】CCF-A(AAAI'21)Game of Gradients: Mitigating Irrelevant Clients in Federated Learning
  • git bash报错fatal: detected dubious ownership in repository at的解决方法
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • ms sql in 优化
  • 立案诉调 All In One
  • Early lameness detection in dairy cattle based on wearable gait analysis using semi-supervised LSTM-Autoencoder
  • [翻译]-Query and Transaction size in MySQL
  • 基于正则化的图自编码器在推荐算法中的应用 Application of graph auto-encoders based on regularization in recommendation algorithms
  • mybatisplus in 查询超过1000的工具类
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们