当前位置:网站首页>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 ~
边栏推荐
- Construction and maintenance of business websites [4]
- 读博士吧,研究奶牛的那种!鲁汶大学 Livestock Technology 组博士招生,牛奶质量监测...
- Detailed explanation of OSI seven layer model
- pyqt图片解码 编码后加载图片
- VictoriaMetrics 简介
- How is LinkedList added?
- MySQL learning record (1)
- Write the content into the picture with type or echo and view it with WinHex
- *C语言期末课程设计*——通讯录管理系统(完整项目+源代码+详细注释)
- [dynamic planning] p1220: interval DP: turn off the street lights
猜你喜欢
关于测试用例
Research Report on ranking analysis and investment strategic planning of RFID market competitiveness of China's industrial manufacturing 2022-2028 Edition
Basic IO interface technology - microcomputer Chapter 7 Notes
The neo4j skill tree was officially released to help you easily master the neo4j map database
*C语言期末课程设计*——通讯录管理系统(完整项目+源代码+详细注释)
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
[shutter] statefulwidget component (create statefulwidget component | materialapp component | scaffold component)
[hands on deep learning]02 softmax regression
[use of pointer and pointer and array]
MySQL learning record (7)
随机推荐
China's log saw blade market trend report, technological innovation and market forecast
Market trend report, technical dynamic innovation and market forecast of China's low gloss instrument
[CV] Wu Enda machine learning course notes | Chapter 12
ctf-HCTF-Final-Misc200
Analysis of enterprise financial statements [1]
[shutter] statefulwidget component (pageview component)
7. Build native development environment
Common routines of compressed packets in CTF
Cloud computing technology [2]
MySQL learning record (4)
rwctf2022_ QLaaS
Hot backup routing protocol (HSRP)
[dynamic planning] p1220: interval DP: turn off the street lights
kernel tty_ struct
Redis分布式锁故障,我忍不住想爆粗...
Today, I met a Alipay and took out 35K. It's really sandpaper to wipe my ass. it's a show for me
Browser - clean up the cache of JS in the page
~91 rotation
D4:非成对图像去雾,基于密度与深度分解的自增强方法(CVPR 2022)
[shutter] statefulwidget component (bottom navigation bar component | bottomnavigationbar component | bottomnavigationbaritem component | tab switching)