注意PC要与31.

 #include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 40
#define MAXL 10 char mem[MAXN][MAXL];
char ans[MAXL]; int getv(char s[], int i, int j) {
int ret = ; while (i < j) {
ret = (ret<<) + s[i] - '';
++i;
} return ret;
} void store(char s[], unsigned char acc) {
int i = ;
int v = (int)acc;
int mask = 0x80; for (i=; i<; ++i) {
if (v & mask) {
s[i] = '';
} else {
s[i] = '';
}
mask >>= ;
}
s[i] = '\0';
} void solve() {
int op, addr;
int tmp;
bool nhalt = true;
unsigned char acc = ;
int pc = ; while (nhalt) {
pc &= 0x1f;
op = getv(mem[pc], , );
addr = getv(mem[pc], , );
++pc;
switch (op) {
case :
store(mem[addr], acc);
break; case :
tmp = getv(mem[addr], , );
acc = (unsigned char) tmp;
break; case :
if (acc == )
pc = addr;
break; case :
break; case :
--acc;
break; case :
++acc;
break; case :
pc = addr;
break; case :
nhalt = false;
break; default:
break;
}
} store(ans, acc);
} int main() {
int i; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif while () {
i = ;
if (scanf("%s", mem[i++]) == EOF)
break;
while (i < )
scanf("%s", mem[i++]);
solve();
printf("%s\n", ans);
} return ;
}

【HDOJ】1341 Simple Computers的更多相关文章

  1. 【HDOJ】2451 Simple Addition Expression

    递推,但是要注意细节.题目的意思,就是求s(x) = i+(i+1)+(i+2),i<n.该表达中计算过程中CA恒为0(包括中间值)的情况.根据所求可推得.1-10: 31-100: 3*41- ...

  2. 【HDOJ】1497 Simple Library Management System

    链表. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXM 1001 #def ...

  3. 【BZOJ3489】A simple rmq problem(KD-Tree)

    [BZOJ3489]A simple rmq problem(KD-Tree) 题面 BZOJ 题解 直接做肯定不好做,首先我们知道我们是一个二维平面数点,但是限制区间只能出现一次很不好办,那么我们给 ...

  4. 【BZOJ3489】A simple rmq problem

    [BZOJ3489]A simple rmq problem 题面 bzoj 题解 这个题不强制在线的话随便做啊... 考虑强制在线时怎么搞 预处理出一个位置上一个出现的相同数的位置\(pre\)与下 ...

  5. 【BZOJ3489】A simple rmq problem kd-tree

    [BZOJ3489]A simple rmq problem Description 因为是OJ上的题,就简单点好了.给出一个长度为n的序列,给出M个询问:在[l,r]之间找到一个在这个区间里只出现过 ...

  6. 【poj3468】A Simple Problem with Integers

    Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 97008   Accepted: 30285 Case Time Limi ...

  7. 【HDOJ】4267 A Simple Problem with Integers

    树状数组.Easy. /* 4267 */ #include <iostream> #include <string> #include <map> #includ ...

  8. 【HDOJ】1088 Write a simple HTML Browser

    题目其实不难,但是要注意题目的要求,当前字数(>0)+当前单词长度+1若超过80则需要回车后,输出当前word,并且重新计数.这道题目的数据感觉比较水,不过测试的时候,最后使用fprintf输出 ...

  9. 【HDOJ】4972 A simple dynamic programming problem

    水题. #include <cstdio> #include <cstring> #include <cstdlib> int abs(int x) { ? -x: ...

随机推荐

  1. ZOJ1221 && UVA567:Risk(Floyd)

    Risk is a board game in which several opposing players attempt to conquer the world. The gameboard c ...

  2. Mysql事务及行级锁的理解

    在最近的开发中,碰到一个需求签到,每个用户每天只能签到一次,那么怎么去判断某个用户当天是否签到呢?因为当属表设计的时候,每个用户签到一次,即向表中插入一条记录,根据记录的数量和时间来判断用户当天是否签 ...

  3. 【Unity3D自我记录】解决NGUI通过问题触发事件点

    在虚拟现实的游戏开发或当,人们功能操作,人们走一下地面行动.但随后点击界面button什么时候,会不会触发click事件.这是通过点.当然,点击界面button当相同的触发点接地运行操作,样也是点透 ...

  4. 高效JQuery编码

    缓存变量 DOM遍历是昂贵的,所以尽量将会重用的元素缓存. // 糟糕   h = $('#element').height(); $('#element').css('height',h-20); ...

  5. Linux Mysql如何移动MySQL数据库目录位置

      假如要把目录移到/home/data下需要进行下面几步: 1.home目录下建立data目录 cd /home mkdir data 2.把MySQL服务进程停掉: mysqladmin -u r ...

  6. cocos2d-x CCAction:动作(转)

    透明度变化的功能挺不错.   瞬时动作 瞬时动作不需要时间,立即完成 [cpp]   //放置,=setPosition()   pRole->runAction(CCPlace::create ...

  7. git 取消追踪

    git rm --cached filePath这个操作不会删除这个文件

  8. NS2仿真:公交车移动周期模型及性能分析

    NS2仿真实验报告3 实验名称:公交车移动周期模型及性能分析 实验日期:2015年3月16日~2015年3月21日 实验报告日期:2015年3月22日 一.实验环境(网络平台,操作系统,网络拓扑图) ...

  9. 一个中高级PHP工程师所应该具备的能力

    很多面试,很多人员能力要求都有“PHP高级工程师的字眼”,如果您真心喜欢PHP,并且您刚起步,那么我简单说说一个PHP高级工程师所应该具备的,希望给初级或已经达到中级的PHP工程师一些帮助. 一.平静 ...

  10. 【转】AFNetworking之于https认证

    转自:http://www.cocoachina.com/ios/20161220/18393.html 写在开头: 本来这篇内容准备写在AFNetworking到底做了什么?(三)中的,但是因为我想 ...