当前位置:网站首页>Counting garlic guest: the solution of the equation
Counting garlic guest: the solution of the equation
2022-04-23 01:25:00 【OldLeft】


The sample input :
3
100
1 2
-1 2
1 2
Sample output
104
Answer key :
Adopt the idea of violence , Enumerate each x All possible values , Then judge whether the calculation result is 0. Pay attention to pretreatment , Otherwise it will time out .
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,ans;
int k[10],p[10];
ll x[10][150];
void dfs(int ind,ll s){
if(ind>n) return;
if(ind==n){
// Recursive export
if(s==0){
// Check whether the calculation result is 0
ans++;
}
return;
}
for(int i=1;i<=m;i++){
// Enumeration solution
dfs(ind+1,s+x[ind][i]);
}
}
int main(){
cin>>n;
cin>>m;
for(int i=0;i<n;i++){
cin>>k[i]>>p[i];
for(int j=1;j<=m;j++){
x[i][j]=k[i]*pow(j,p[i]);// Preprocessing
}
}
dfs(0,0);
cout<<ans<<endl;
return 0;
}
版权声明
本文为[OldLeft]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230120462576.html
边栏推荐
- GBase8s SQL 引擎框架简介
- Linked list dynamic header insertion
- [蓝桥杯][2019年第十届真题]外卖店优先级
- 那些咸鱼上买来的代码|ssm酒店客房管理系统|买来的源码是否真的可以使用|来自程序员的困惑|玉念聿辉|大丑村吴明辉
- Here's the point. Have you mastered the most complete Web3 jargon guide?
- 四级城市地区表 xlsx, sql文件,国内,中国省市县街道乡镇四级地址 (名称,联动ID,层级,是否末级(1-是))
- 12 years of testing predecessors give you some suggestions for learning software testing
- 找数字(DFS)
- 2022 penetration job interview (thinking)
- Unrelated interprocess communication -- creation and use of named pipes
猜你喜欢

How to introduce SPI into a project

Use Charles to grab app package

Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"

API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)

In depth report: in the heterogeneous era, chips need to integrate multiple templates

无关联进程间通信 —— 命名管道的创建和使用

From thinking to practice, digital transformation is the successful path of it operation

VS+C# 实现窗体输入框默认显示灰色文字

Innovative practice of short video content understanding and generation technology in meituan

Google developer tool preserve log
随机推荐
Introduction to gbase 8s shared memory buffer pool
清研环境深交所上市:年营收1.8亿 市值41亿
Gbase 8s group by function introduction
Scope of define
直播软件|IPTV直播软件|电视直播|TVPlayer-IPTV-EasyPlayer|友窝直播|超级直播软件定制开发
JD side: how can a child thread get the value of the parent thread ThreadLocal? I got...
Basic operation of Android local database | multi thread operation database | addition, deletion, modification and query of database | batch insertion into database | basic use of thread pool | Yu nia
引爆炸弹(DFS)
Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"
Unity combines itextsharp to generate PDF preparation DLL
gin--hello
全排列(DFS和next_permutation解法)
[the first contact between Android engineers and smart home products ③] the specific implementation of smartconfig one key distribution network on the hardware side | the specific implementation of es
World reading day: 18 it books with Douban score above 9.0 are worth collecting
[JS] realize the export of PDF from the specified area of the web page
What is the legal basis and procedure for Tami dog sharing | state owned equity transfer?
GBase 8t索引
Get rid of the "small workshop" of AI production: how to build a cloud native AI platform based on kubernetes
Branch and loop statements
深入解析Linux下的磁盘缓存机制与SSD的写入放大问题