HDU 5083 Instruction(字符串处理)】的更多相关文章

Problem Description Nowadays, Jim Green has produced a kind of computer called JG. In his computer, the instruction is represented by binary code. However when we code in this computer, we use some mnemonic symbols. For example, ADD R1, R2 means to a…
Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 347    Accepted Submission(s): 101 Problem Description Nowadays, Jim Green has produced a kind of computer called JG. In his computer…
题意:给出汇编指令,解释出编码或者给出编码,解释出汇编指令. 解法:简单模拟,按照给出的规则一步一步来就好了,主要是注意“SET”的情况,还有要输出的东西最好放到最后一起输出,中间如果一旦不对就可以及时跳出去. 其他也没什么了,只要细心点,多测几组样例就好了. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath&g…
题意: 二进制指令转汇编指令,汇编指令转二进制指令. 思路: 额,条理分好,想全,思维不能乱. 代码: int findyu(char yu[50],char c){ int l=strlen(yu); rep(i,0,l-1) if(c==yu[i]) return i; } int calc(char t[50],int x,int k){ int res=0; rep(i,x,x+k-1) res*=10, res+=(t[i]-'0'); return res; } int calc2(…
题目链接:HDU 1274 展开字符串 中文题. 左括号进入DFS函数,右括号return到上一层. 注意return回去的是这个一层递归中的括号中的字母串. AC代码: #include<stdio.h> #include<iostream> #include<string.h> #include<string> using namespace std; char str[300]; bool vis[300]; int len; string dfs(i…
Bazinga Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2287    Accepted Submission(s): 713 Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5083 题目意思:如果给出 instruction 就需要输出对应的 16-bit binary code,给出16-bit binary code 就需要输出对应的instruction. 由于不会截取的技巧,代码量非常可观 = =,所以说,一直很讨厌做模拟题!!! 留下这代码,纪念一个代码还是不够精简的自己!!!内存和时间还能接受,也比较容易理解,不过好多重复代码= =.以下这个代码可以忽略,改到…
http://acm.hdu.edu.cn/showproblem.php?pid=5083 机器码和操作互相转化 注意SET还要判断末5位不为0输出Error #pragma comment(linker, "/STACK:36777216") #pragma GCC optimize ("O2") #include <cstdio> #include <cstdlib> #include <cmath> #include &l…
Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 343    Accepted Submission(s): 99 Problem Description Nowadays, Jim Green has produced a kind of computer called JG. In his computer,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4622 题意:给定一个长度不超过2000的字符串,之后有不超过1e5次的区间查询,输出每次查询区间中不同的子串个数? 做法1:字符串hash 一般的做法就是模拟每段子串的长度L(从1到 len),这样时间复杂度为O(n^2);但是里面并没有计算子串比较是否相等以及存储的时间,而这段时间就是将字符串看成是“数字”,这样存储和比较的时间均降为O(1)了: 下面讲讲模板: 1.如何将字符串看成一个“高精度的…