abc233_c Product 题解
Product
题意
有
从每个集合中选取一个数,问:有多少种取法使得取出的数的乘积为
数据范围
思路
这题其实很easy,只需要爆搜就可以AC了。
可以分析出
由于题目给的数据范围限制了
复杂度
时间:
空间:
Code
点击查看代码
#include <iostream> #include <vector> #include <queue> using namespace std; using ll = long long; const int L = 1e5 + 10; int n, ans, l[20], a[20][L]; ll x; void dfs (int t, ll y) { if (y > x || y < 1) { return ; } if (t == n + 1) { if (y == x) { ans++; } return ; } for (int i = 1; i <= l[t]; i++) { dfs(t + 1, y * a[t][i]); } } int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> l[i]; for (int j = 1; j <= l[i]; j++) { cin >> a[i][j]; } } dfs(1, 1); cout << ans; return 0; }
本文作者:wnsyou の blog
本文链接:https://www.cnblogs.com/wnsyou-blog/p/17168659.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步