当前位置:网站首页>Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)
Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)
2022-07-02 21:41:00 【Woodenman Du】
Question:
Result:64
Solve:
DFS to flash back , Just try one by one and fill in a few , And then TLE 了
Two questions :
First of all : Run completely 13 Try a few , Will be Fried , We need to get rid of the impossible plan in advance , For example, fill in the first line , I'll see if the first formula works
second : Division in the standard answer of this question is only divisible , instead of “/”, Then it led me to look at my 1376 Dazed for a long time , Great speechless event
Code:
#include <bits/stdc++.h>
using namespace std;
bool a[14];
int num[13];
int res = 0;
void dfs(int deep)
{
// Remove in advance
if(deep > 3 && num[1] + num[2] != num[3])return ;
if(deep > 6 && num[4] - num[5] != num[6])return ;
if(deep > 9 && num[7] * num[8] != num[9])return ;
// Final judgment
if(deep > 12)
{
if(num[10] / num[11] == num[12] && num[10]%num[11] == 0)
res++;
return ;
}
// Search for
for(int i = 1; i <= 13; i++){
if(a[i] == true) continue;
num[deep] = i; a[i] = true;
dfs(deep+1);
// to flash back
a[i] = false;
}
}
int main(void)
{
memset(a,false,sizeof(a));
dfs(1);
cout <<res;
return 0;
}
Statement : The pictures are from the official website of the Blue Bridge Cup , For the purpose of sorting out personal questions , In case of infringement , Please contact to delete ~
边栏推荐
- treevalue——Master Nested Data Like Tensor
- MySQL learning record (9)
- How to test the process of restoring backup files?
- Structure array, pointer and function and application cases
- D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
- ~91 rotation
- Construction and maintenance of business website [1]
- MySQL learning record (1)
- Codeworks global round 19 (CF 1637) a ~ e problem solution
- Interpretation of some papers published by Tencent multimedia laboratory in 2021
猜你喜欢
qwb2018_ core kernel_ rop
Unexpectedly, there are such sand sculpture code comments! I laughed
MySQL learning record (9)
[dynamic planning] p1220: interval DP: turn off the street lights
In depth research and investment feasibility report of global and Chinese isolator industry, 2022-2028
[hands on deep learning]02 softmax regression
Analysis of neural network
Welfare, let me introduce you to someone
26 FPS video super-resolution model DAP! Output 720p Video Online
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
随机推荐
[dynamic planning] p1220: interval DP: turn off the street lights
Accounting regulations and professional ethics [16]
Welfare | Pu Aries | liv heart co branded Plush surrounding new products are on the market!
Construction and maintenance of business websites [9]
Read a doctor, the kind that studies cows! Dr. enrollment of livestock technology group of Leuven University, milk quality monitoring
China microporous membrane filtration market trend report, technological innovation and market forecast
China plastic bottle and container market trend report, technological innovation and market forecast
Redis分布式锁故障,我忍不住想爆粗...
China's crude oil heater market trend report, technological innovation and market forecast
~91 rotation
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
rwctf2022_ QLaaS
Research Report on right-hand front door industry - market status analysis and development prospect forecast
A river of spring water flows eastward
[use of pointer and pointer and array]
China plastic bottle market trend report, technological innovation and market forecast
Jar package startup failed -mysql modify the default port number / set password free enter
MySQL learning notes (Advanced)
Physical layer cables and equipment
读博士吧,研究奶牛的那种!鲁汶大学 Livestock Technology 组博士招生,牛奶质量监测...