当前位置:网站首页>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
边栏推荐
- 自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
- Lora sync word settings
- 第4章:再谈类的加载器
- qt quick项目offscreen模式下崩溃的问题处理
- Improving Multimodal Accuracy Through Modality Pre-training and Attention
- Sword finger offer question brushing record 1
- Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
- Data storage (1)
- i. Mx6ull build boa server details and some of the problems encountered
- Memorabilia of domestic database in June 2022 - ink Sky Wheel
猜你喜欢

CocosCreator+TypeScripts自己写一个对象池

Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)

uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)

基于 QEMUv8 搭建 OP-TEE 开发环境

2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行

Clip +json parsing converts the sound in the video into text
![[线性代数] 1.3 n阶行列式](/img/6e/54f3a994fc4c2c10c1036bee6715e8.gif)
[线性代数] 1.3 n阶行列式

(十八)LCD1602实验

重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障

leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
随机推荐
What are the specific steps and schedule of IELTS speaking?
TypeScript获取函数参数类型
做接口测试都测什么?有哪些通用测试点?
Learn the principle of database kernel from Oracle log parsing
[linear algebra] determinant of order 1.3 n
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
CCNA Cisco network EIGRP protocol
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
Sizeof keyword
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
视图(view)
Spatial domain and frequency domain image compression of images
(十八)LCD1602实验
重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
Senior soft test (Information System Project Manager) high frequency test site: project quality management
枚举与#define 宏的区别
使用云服务器搭建代理
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
如何用程序确认当前系统的存储模式?