iBoard

After years of success with a single-button mouse, a well known computer company has decided to offer a similarly simplified interface for the keyboard. The iBoard has only two keys. The user types by entering the ASCII code for each letter. To help people type faster, the iBoard uses key press and key release transitions to enter characters. Pressing or releasing the right key enters zero for the next bit. Pressing or releasing the left key enters a one. The binary code for each 7-bit ASCII character is entered starting with the least significant bit and working up to the most significant bit. For example, to type a capital Z, the user simply has to press the right key, press the left key, release the right key, release the left key, press the left key, press the right key and then release the left key.

Although its creators would like you to believe that the iBoard is far superior to any other keyboard, it does have one disadvantage. The operator may not be free to get up and go to the bathroom as soon as he or she needs to. After typing a string of characters, the user may be stuck with one or more fingers pressing iBoard keys. Releasing these keys would begin typing the next character. Your job is to write a program that determines when it’s safe to get up and leave the keyboard. Your program should read input strings and report if it’s safe to get up and leave the iBoard after typing each string.

Input

Input contains up to 100 strings, one per line, terminated at end of file. Each string has between 1 and 100 ASCII characters. End-of-line characters should not be considered part of each string.

Output

For each input string, print out a line reporting either trapped or free. The user is considered trapped if one or more iBoard keys is still being pressed after the string is typed. Otherwise, the user is free. You should assume that no iBoard keys are being pressed when the user starts typing the string.

Sample Input 1 Sample Output 1
Keep up the good work.
iBoard Rules!!
qwerty
trapped
free
trapped

题意

死于读题。。看样例我以为是有关键词“iBoard”就输出free,然后连续wa,这题就我Wa最多。。咳咳,让我们来个正确的题意。

将每个字符的ascii码放进去化成二进制,并且不足7位就补0
所有的东西,除了换行符,都要敲入的,空格一样要读入,用getline读。
如果是1 则按下左键,如果按着就松开, 如果是0 就按右键,如果按着就松开,输完一段话,如果两个手指头还有一个地方按着,则视为被绑住了 trapped, 否则free。

思路

这就成了一个化二进制的问题了,仅此而已

代码

#include<bits/stdc++.h>
using namespace std;
int l = , r = ;
void bin2(int a) {
int has = ;
while (a) {
if (a & ) l = !l;
else r = !r;
a /= ;
has++;
}
while (has++ < )r = !r;
}
int main() {
string s;
while (getline(cin, s)) {
l = r = ;
for (int i = ; i < s.size(); i++) {
bin2((int)s[i]);
}
if (l || r)
printf("trapped\n");
else printf("free\n");
}
}

Kattis - iBoard的更多相关文章

  1. 【iCore、iCore2、iBoard例程】【异步FIFO跨时钟域通信(通过ARM 读FPGA FIFO)】

    欢迎访问电子工程师学堂,以便了解更多内容:http://www.eeschool.org 一.本实验基于iCore2 完成,通过简单改动,即可用在 iCore 核心板.iBoard 电子学堂上. iC ...

  2. 【iBoard电子学堂】【iCore双核心板】资料光盘A盘更新,版本号为A6

    _____________________________________ 深入交流QQ群: A: 204255896(1000人超级群,可加入) B: 165201798(500人超级群,满员) C ...

  3. 【iBoard电子学堂开发板例程】【12个 stm32 例程发布】

    _____________________________________ 深入交流QQ群: A: 204255896(1000人超级群,可加入) B: 165201798(500人超级群,满员) C ...

  4. It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)

    题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...

  5. A - Piece of Cake Kattis - pieceofcake (数学)

    题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...

  6. Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)

    题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...

  7. G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)

    题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...

  8. E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)

    题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...

  9. G - Galactic Collegiate Programming Contest Kattis - gcpc (set使用)

    题目链接: G - Galactic Collegiate Programming Contest Kattis - gcpc 题目大意:当前有n个人,一共有m次提交记录,每一次的提交包括两个数,st ...

随机推荐

  1. 关于 多个git用户或多个git管理工具切换时出现的问题总结

    在这几天遇到了个比较头痛的问题 因为在同时使用多个git工具(gitlab,github.gitee)由于账户的问题和这个仓库指定地址,导致拉代码和推代码不能正常运行 问题解决: 对于多个git直接的 ...

  2. elasticsearch6.4中文文档

    男朋友翻译的,我这边做一个查看入口,分享给大家,O(∩_∩)O哈哈~ 版权声明:本文为博主原创文章,无需授权即可转载,甚至无需保留以上版权声明,转载时请务必注明作者. https://blog.csd ...

  3. android 集成支付宝app支付(原生态)-包括android前端与java后台

    本文讲解了 android开发的原生态app集成了支付宝支付, 还提供了java后台服务器处理支付宝支付的加密代码, app前端与java后台服务器使用json数据格式交互信息,java后台服务主要用 ...

  4. 在java中,怎样跳出当前的多重循环?

    </pre>直接用break ;详细举比例如以下:<p></p><p></p><p></p><pre name ...

  5. jQuery高性能自己定义滚动栏美化插件

    malihu是一款高性能的滚动栏美化jQuery插件. 该滚动栏美化插件支持水平和垂直滚动栏,支持鼠标滚动,支持键盘滚动和支持移动触摸屏. 而且它能够和jQuery UI和Bootatrap完美的结合 ...

  6. UVA11234 Expressions

    题目的意思实在是读不懂,又是把栈变成队列什么的.. 只是大体的意思就是把后缀表达式变一下.. 抛开意思,事实上就是依据输入建个树,然后倒序输出.. 拿第一个例子说明:大写代表操作符(+ - × /之类 ...

  7. 用SecureCRT在linux系统下载文件

    使用sz命令 说明如下: sz --helpsz version 0.12.20Usage: sz [options] file ...   or: sz [options] -{c|i} COMMA ...

  8. ubuntu之修改ls显示颜色

    Linux 系统中 ls 文件夹的痛苦我就不说了,为了不伤眼睛,一般 ssh 终端背景都用的黑色,文件夹又是你妈的深蓝色,每次看文件夹都要探头仔细去看.这下彻底解决这个问题.   因为ubuntu下的 ...

  9. poj--2553--The Bottom of a Graph (scc+缩点)

    The Bottom of a Graph Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Oth ...

  10. 几款jQuery右键菜单插件介绍

    在网页中使用自定义右键菜单,实现上皆为使用javascript禁用浏览器默认的右键菜单,然后在网页中响应鼠标右键事件,弹出自定义的菜单. 类似右键菜单的组件网上很多.一般而言,改变浏览器的默认菜单应当 ...