当前位置:网站首页>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 ~
边栏推荐
- Research Report on ranking analysis and investment strategic planning of RFID market competitiveness of China's industrial manufacturing 2022-2028 Edition
- 7. Build native development environment
- Report on investment development and strategic recommendations of China's vibration isolator market, 2022-2027
- D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
- China plastic box market trend report, technological innovation and market forecast
- Today, I met a Alipay and took out 35K. It's really sandpaper to wipe my ass. it's a show for me
- I drew a Gu ailing with characters!
- Research Report on micro vacuum pump industry - market status analysis and development prospect prediction
- Research Report on market supply and demand and strategy of China's plastic pump industry
- Welfare | Hupu isux11 Anniversary Edition is limited to hand sale!
猜你喜欢
Redis distributed lock failure, I can't help but want to burst
关于测试用例
D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
Volvo's first MPV is exposed! Comfortable and safe, equipped with 2.0T plug-in mixing system, it is worth first-class
如何防止你的 jar 被反编译?
Check the confession items of 6 yyds
[error record] the command line creates an error pub get failed (server unavailable) -- attempting retry 1 in 1 second
MySQL learning record (8)
读博士吧,研究奶牛的那种!鲁汶大学 Livestock Technology 组博士招生,牛奶质量监测...
[shutter] statefulwidget component (bottom navigation bar component | bottomnavigationbar component | bottomnavigationbaritem component | tab switching)
随机推荐
Interpretation of some papers published by Tencent multimedia laboratory in 2021
D4: unpaired image defogging, self enhancement method based on density and depth decomposition (CVPR 2022)
Get weekday / day of week for datetime column of dataframe - get weekday / day of week for datetime column of dataframe
Analysis of enterprise financial statements [1]
I drew a Gu ailing with characters!
kernel tty_ struct
Codeworks global round 19 (CF 1637) a ~ e problem solution
Hot backup routing protocol (HSRP)
Unexpectedly, there are such sand sculpture code comments! I laughed
Adding data to the head or tail of the rar file can still decompress normally
[dynamic planning] p1220: interval DP: turn off the street lights
Research Report on micro gripper industry - market status analysis and development prospect prediction
System (hierarchical) clustering method and SPSS implementation
Research Report on right-hand front door industry - market status analysis and development prospect forecast
Go cache of go cache series
Sword finger offer (I) -- handwriting singleton mode
D4:非成对图像去雾,基于密度与深度分解的自增强方法(CVPR 2022)
rwctf2022_ QLaaS
[C language] [sword finger offer article] - replace spaces
Construction and maintenance of business website [1]