当前位置:网站首页>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
边栏推荐
- Aardio - 不声明直接传float数值的方法
- [Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
- 做国外LEAD2022年下半年几点建议
- Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
- SQL Server生成自增序号
- [linear algebra] determinant of order 1.3 n
- 重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
- Aardio - 利用customPlus库+plus构造一个多按钮组件
- Learn the principle of database kernel from Oracle log parsing
- Spatial domain and frequency domain image compression of images
猜你喜欢
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
config:invalid signature 解决办法和问题排查详解
pytorch_ Yolox pruning [with code]
Learn the principle of database kernel from Oracle log parsing
MySQL数据库基本操作-DML
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
每日一题:力扣:225:用队列实现栈
将MySQL的表数据纯净方式导出
软考高级(信息系统项目管理师)高频考点:项目质量管理
LeetCode 练习——剑指 Offer 26. 树的子结构
随机推荐
CCNA Cisco network EIGRP protocol
基於 QEMUv8 搭建 OP-TEE 開發環境
2022-07-05 stonedb sub query processing parsing time analysis
2022-07-05 使用tpcc对stonedb进行子查询测试
rust知识思维导图xmind
NPDP certification | how do product managers communicate across functions / teams?
Dealing with the crash of QT quick project in offscreen mode
Improving Multimodal Accuracy Through Modality Pre-training and Attention
做接口测试都测什么?有哪些通用测试点?
config:invalid signature 解决办法和问题排查详解
uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
return 关键字
Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
云原生技术--- 容器知识点
UDP programming
变量与“零值”的比较
将MySQL的表数据纯净方式导出
基于 QEMUv8 搭建 OP-TEE 开发环境
Sizeof keyword