ABC233C

ABC233C Product - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

C - Product (atcoder.jp)

cpp 复制代码
#include <bits/stdc++.h>
#define long long int
using namespace std;
int n,x;
int total=0;
vector<vector<int> > vec;
void dfs(int pos,int pro){
	//位置,乘积
	if(pos==(n+1)){
		if(pro==x){
			total++;
		}
		return ;
	}
	for(int i=1;i<vec[pos].size();i++){
		int c=vec[pos][i];
		if(c>x/pro||x%c!=0){
			continue;
		}
		dfs(pos+1,pro*c);
	}
	return ;
}
signed main(){
	cin>>n>>x;
	vec.resize(n+1);
	int l;
	for(int i=1;i<=n;i++){
		cin>>l;
		vec[i].resize(l+1);
		for(int j=1;j<=l;j++){
			cin>>vec[i][j];
		}
	}
	dfs(1,1);
	cout<<total<<endl;
	return 0;
}
相关推荐
美团技术团队3 小时前
LongCat 开源 VitaBench 2.0:长期动态智能体基准新标杆
人工智能·算法
To_OC20 小时前
LC 207 课程表:刚学图论那会儿,我连这是拓扑排序都没看出来
javascript·算法·leetcode
To_OC20 小时前
LC 208 实现 Trie 前缀树:曾被名字劝退,写完发现是送分题
javascript·算法·leetcode
BadBadBad__AK1 天前
线段树维护区间 k 次方和
c++·数学·算法·stl
_清歌1 天前
DSpark 深度解读:DeepSeek-V4 如何用「半自回归」把推理速度提升 85%
算法
统计实现局1 天前
SVD 的三步走:双对角化、Givens 收敛、排序
算法
躬行见万象1 天前
《VLA 系列》UniLab 强化训练 | G1 机器人 |复现
算法
统计实现局1 天前
对称不定分解(Bunch-Kaufman):为什么 Cholesky 不够用
算法
统计实现局1 天前
dqrsl 拆解:拿着 QR 结果能算出哪 5 种东西
算法