当前位置:网站首页>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
边栏推荐
- Config:invalid signature solution and troubleshooting details
- Research and investment strategy report of China's VOCs catalyst industry (2022 Edition)
- Dealing with the crash of QT quick project in offscreen mode
- poj 1094 Sorting It All Out (拓扑排序)
- Windows Auzre 微软的云计算产品的后台操作界面
- Clip +json parsing converts the sound in the video into text
- TypeScript获取函数参数类型
- Spatial domain and frequency domain image compression of images
- Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
- 2022-07-05 stonedb的子查询处理解析耗时分析
猜你喜欢

Crawler obtains real estate data

自制J-Flash烧录工具——Qt调用jlinkARM.dll方式

Chapter 4: talk about class loader again

MySQL ---- first acquaintance with MySQL

labelimg的安装与使用

Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"

Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution

Config:invalid signature solution and troubleshooting details

视图(view)

Should novice programmers memorize code?
随机推荐
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
基於 QEMUv8 搭建 OP-TEE 開發環境
2022-07-05 使用tpcc对stonedb进行子查询测试
Inno Setup 打包及签名指南
memcached
树的先序中序后序遍历
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
volatile关键字
二分图判定
Anaconda installs third-party packages
Should novice programmers memorize code?
UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop
TypeScript获取函数参数类型
MySQL约束的分类、作用及用法
The nearest common ancestor of binary (search) tree ●●
The SQL response is slow. What are your troubleshooting ideas?
基于 QEMUv8 搭建 OP-TEE 开发环境
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
云原生技术--- 容器知识点
npm无法安装sharp