当前位置:网站首页>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 ~
边栏推荐
- MySQL learning record (7)
- Basic IO interface technology - microcomputer Chapter 7 Notes
- rwctf2022_ QLaaS
- Record the problems encountered by nodejs asynchronism
- Research Report on crude oil tanker industry - market status analysis and development prospect forecast
- treevalue——Master Nested Data Like Tensor
- The web version of xshell supports FTP connection and SFTP connection [detailed tutorial] continued from the previous article
- Structured text language XML
- Construction and maintenance of business website [2]
- MySQL learning record (5)
猜你喜欢

In depth research and investment feasibility report of global and Chinese isolator industry, 2022-2028

Write the content into the picture with type or echo and view it with WinHex
![[shutter] the shutter plug-in is used in the shutter project (shutter plug-in management platform | search shutter plug-in | install shutter plug-in | use shutter plug-in)](/img/80/215499c66243d5a4453d8e6206c012.jpg)
[shutter] the shutter plug-in is used in the shutter project (shutter plug-in management platform | search shutter plug-in | install shutter plug-in | use shutter plug-in)

How to test the process of restoring backup files?
![[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology](/img/2f/bb99836bb3ad725483f30531ff4d53.jpg)
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology

Redis distributed lock failure, I can't help but want to burst

6 pyspark Library

I drew a Gu ailing with characters!

5 environment construction spark on yarn

D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
随机推荐
Internet Explorer ignores cookies on some domains (cannot read or set cookies)
【零基础一】Navicat下载链接
Construction and maintenance of business website [5]
[shutter] shutter layout component (fractionallysizedbox component | stack layout component | positioned component)
Accounting regulations and professional ethics [18]
How to prevent your jar from being decompiled?
26 FPS video super-resolution model DAP! Output 720p Video Online
[CV] Wu Enda machine learning course notes | Chapter 12
D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
kernel_ uaf
MySQL learning record (8)
In depth research and investment feasibility report on the global and China active vibration isolation market 2022-2028
[error record] the command line creates an error pub get failed (server unavailable) -- attempting retry 1 in 1 second
Micro SD Card Industry Research Report - market status analysis and development prospect forecast
Welfare | Hupu isux11 Anniversary Edition is limited to hand sale!
Three chess games
Browser - clean up the cache of JS in the page
[shutter] statefulwidget component (image component | textfield component)
[shutter] shutter layout component (physicalmodel component)
What is the difference between programming in real work and that in school?