当前位置:网站首页>HDU 5077 NAND (violent tabulation)
HDU 5077 NAND (violent tabulation)
2022-07-06 22:33:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
The main idea of the topic :Xiaoqiang To write a coding program , Then according to x1,x2,x3 The value of constructs 8 Characters . Now given the requirements generated 8 Characters . ask
say Xiaoqiang At least how many lines of code to write . The code content can only be NAND Operation and return operation , The variables of the operation can be constants .
Their thinking : Enter a total of 256 Medium condition , So violent pruning and beating table , The code for typing tables has been deleted ... So let's think about it . Open one s Array
Said variable , Then two variables at each time for each layer NAND operation .
Roughly three pruning ,dfs When , When variables appear, skip .8 Characters can be calculated directly according to the bit operation of numbers ; The same skip occurs in the previous layer .
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int ans[300] = {1, 5, 6, 3, 6, 3, 7, 4, 7, 8, 4, 5, 4, 5, 4, 1, 6, 3, 7, 4, 7, 4, 9, 7, 8, 8, 7, 5, 7, 5, 7, 4, 7, 8, 4, 5, 8, 8, 7, 5, 8, 9, 5, 6, 8, 8, 5, 5, 4, 5, 4, 1, 7, 5, 7, 4, 8, 8, 5, 5, 5, 7, 6, 4, 7, 8, 8, 8, 4, 5, 7, 5, 8, 9, 8, 8, 5, 6, 5, 5, 4, 5, 7, 5, 4, 1, 7, 4, 8, 8, 5, 7, 5, 5, 6, 4, 8, 9, 8, 8, 8, 8, 5, 7, 11, 9, 8, 9, 8, 9, 8, 8, 5, 6, 5, 5, 5, 5, 6, 4, 8, 9, 8, 8, 8, 8, 8, 7, 8, 9, 9, 9, 9, 9, 10, 9, 5, 7, 6, 6, 6, 6, 7, 6, 9, 9, 10, 9, 10, 9, 10, 10, 7, 6, 7, 7, 7, 7, 9, 7, 5, 7, 6, 6, 7, 6, 7, 7, 5, 6, 2, 3, 6, 6, 4, 3, 6, 6, 7, 6, 7, 7, 9, 7, 6, 6, 4, 3, 7, 7, 7, 6, 5, 7, 7, 6, 6, 6, 7, 7, 5, 6, 6, 6, 2, 3, 4, 3, 6, 6, 7, 7, 7, 6, 9, 7, 6, 6, 7, 7, 4, 3, 7, 6, 5, 6, 6, 6, 6, 6, 7, 7, 8, 9, 5, 6, 5, 6, 2, 5, 2, 3, 4, 3, 4, 3, 7, 6, 5, 6, 2, 5, 2, 5, 4, 1};
int main () {
int cas;
char p[10];
scanf("%d", &cas);
while (cas--) {
scanf("%s", p);
int ret = 0;
for (int i = 0; i < 8; i++)
ret = ret * 2 + p[i] - '0';
printf("%d\n", ans[ret]);
}
return 0;
}
Copyright notice : This article is the original article of the blogger . Blog , Do not reprint without permission .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116988.html Link to the original text :https://javaforall.cn
边栏推荐
- Mise en place d'un environnement de développement OP - tee basé sur qemuv8
- NPDP certification | how do product managers communicate across functions / teams?
- void关键字
- 2022-07-05 stonedb的子查询处理解析耗时分析
- 0 basic learning C language - interrupt
- MySQL----初识MySQL
- 重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
- How do I write Flask's excellent debug log message to a file in production?
- Inno Setup 打包及签名指南
- (18) LCD1602 experiment
猜你喜欢
Signed and unsigned keywords
Chapter 3: detailed explanation of class loading process (class life cycle)
Memorabilia of domestic database in June 2022 - ink Sky Wheel
【LeetCode】19、 删除链表的倒数第 N 个结点
Advantages of link local address in IPv6
Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
3DMAX assign face map
The SQL response is slow. What are your troubleshooting ideas?
二分图判定
将MySQL的表数据纯净方式导出
随机推荐
signed、unsigned关键字
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
BasicVSR_PlusPlus-master测试视频、图片
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
Gd32f4xx serial port receive interrupt and idle interrupt configuration
Comparison between variable and "zero value"
MySQL教程的天花板,收藏好,慢慢看
The SQL response is slow. What are your troubleshooting ideas?
Puppeteer连接已有Chrome浏览器
Aardio - 通过变量名将变量值整合到一串文本中
Assembly and interface technology experiment 5-8259 interrupt experiment
extern关键字
Daily question 1: force deduction: 225: realize stack with queue
MySQL约束的分类、作用及用法
NetXpert XG2帮您解决“布线安装与维护”难题
Research and investment strategy report of China's VOCs catalyst industry (2022 Edition)
npm无法安装sharp
[IELTS speaking] Anna's oral learning record part1
树的先序中序后序遍历
手写ABA遇到的坑