10399: F.Turing equation

Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 151  Solved: 84 [Submit][Status][Web Board]

Description

The fight goes on, whether to store  numbers starting with their most significant digit or their least  significant digit. Sometimes  this  is also called  the  "Endian War". The battleground  dates far back into the early days of computer  science. Joe Stoy,  in his (by the way excellent)  book  "Denotational Semantics", tells following story:
"The decision  which way round the digits run is,  of course, mathematically trivial. Indeed,  one early British computer  had numbers running from right to left (because the  spot on an oscilloscope tube  runs from left to right, but  in serial logic the least significant digits are dealt with first). Turing used to mystify audiences at public lectures when, quite by accident, he would slip into this mode even for decimal arithmetic, and write  things  like 73+42=16.  The next version of  the machine was  made  more conventional simply  by crossing the x-deflection wires:  this,  however, worried the engineers, whose waveforms  were all backwards. That problem was in turn solved by providing a little window so that the engineers (who tended to be behind the computer anyway) could view the oscilloscope screen from the back.
You will play the role of the audience and judge on the truth value of Turing's equations.

Input

The input contains several test cases. Each specifies on a single line a Turing equation. A Turing equation has the form "a+b=c", where a, b, c are numbers made up of the digits 0,...,9. Each number will consist of at most 7 digits. This includes possible leading or trailing zeros. The equation "0+0=0" will finish the input and has to be processed, too. The equations will not contain any spaces.

Output

For each test case generate a line containing the word "TRUE" or the word "FALSE", if the equation is true or false, respectively, in Turing's interpretation, i.e. the numbers being read backwards.

Sample Input

73+42=16
5+8=13
0001000+000200=00030
0+0=0

Sample Output

TRUE
FALSE
TRUE

HINT

 

Source

题解:把数字反转问等式是否成立;

代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
typedef long long LL;
char s[35],t[10];
int ans[3];
int main(){
while(scanf("%s",s),strcmp(s,"0+0=0")){
int k=0,tp=0,temp=0;
for(int i=0;s[i];i++){
if(isdigit(s[i])){
t[k++]=s[i];
}
else{
reverse(t,t+k);
for(int j=0;j<k;j++)
temp=temp*10+t[j]-'0';
ans[tp++]=temp;
k=0;temp=0;
}
}
reverse(t,t+k);
for(int j=0;j<k;j++)
temp=temp*10+t[j]-'0';
ans[tp++]=temp;
// printf("%d %d %d\n",ans[0],ans[1],ans[2]);
if(ans[0]+ans[1]==ans[2])puts("TRUE");
else puts("FALSE");
}
return 0;
}

  

第七届河南省赛F.Turing equation(模拟)的更多相关文章

  1. 第七届河南省赛10403: D.山区修路(dp)

    10403: D.山区修路 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 69  Solved: 23 [Submit][Status][Web Bo ...

  2. 第七届河南省赛10402: C.机器人(扩展欧几里德)

    10402: C.机器人 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 53  Solved: 19 [Submit][Status][Web Boa ...

  3. 第七届河南省赛G.Code the Tree(拓扑排序+模拟)

    G.Code the Tree Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 18 [Submit][Status][Web ...

  4. 第七届河南省赛B.海岛争霸(并差集)

    B.海岛争霸 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 130  Solved: 48 [Submit][Status][Web Board] D ...

  5. 第七届河南省赛A.物资调度(dfs)

    10401: A.物资调度 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 95  Solved: 54 [Submit][Status][Web Bo ...

  6. 第七届河南省赛H.Rectangles(lis)

    10396: H.Rectangles Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 229  Solved: 33 [Submit][Status] ...

  7. 第八届河南省赛F.Distribution(水题)

    10411: F.Distribution Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 11  Solved: 8 [Submit][Status] ...

  8. 算法笔记_122:蓝桥杯第七届省赛(Java语言A组)试题解答

     目录 1 煤球数目 2 生日蜡烛 3 搭积木 4 分小组 5 抽签 6 寒假作业 7 剪邮票 8 取球博弈 9 交换瓶子 10 压缩变换   前言:以下试题解答代码部分仅供参考,若有不当之处,还请路 ...

  9. 山东省第七届省赛 D题:Swiss-system tournament(归并排序)

    Description A Swiss-system tournament is a tournament which uses a non-elimination format. The first ...

随机推荐

  1. 网站linux.linuxidc.com有很多好资料

    免费下载地址在 http://linux.linuxidc.com/ 用户名与密码都是www.linuxidc.com 有一些介绍:www.linuxidc.com/download

  2. llinuxs介绍与常用命令

    一.Linux系统概述1.计算机资源软件资源硬件资源操作系统2.操作系统WindowsMacOSLinuxUnix3.Linux含义狭义Linux:由Linus一段内核代码广义Linux:Linux厂 ...

  3. java面向对象之 封装 Encapsulation

    什么是封装:对象中的成员该隐藏的隐藏.该公开的要公开 封装:顾名思义,隐藏对象的属性和实现细节,仅对外公开接口,控制在程序中属性的读和修改的访问级别:将抽象得到的数据和行为(或功能)相结合,形成一个有 ...

  4. Scala中的apply实战详解

    apply可以应用与Object和Class,单调用情景不一样. 通过Array(1,2,3,4,5) 可以调用到Array中的.appy方法.你可以看源码是如何实现apply的. 类中的appy比较 ...

  5. verilog中=和<=的区别

    一般情况下使用<=,组合逻辑使用=赋值,时序逻辑使用<=赋值: 举个例子:初始化m=1,n=2,p=3:分别执行以下语句 1.begin m=n:n=p:p=m: end 2.begin ...

  6. Get请求出现乱码的解决方案

    Get请求出现乱码,模拟一般出现的场景.场景一:超链接<a href=”url?name=张三&age=18”>场景二:window.opon(“url?name=张三&a ...

  7. VUE.JS组件化

    VUE.JS组件化 前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎 ...

  8. JS获取年月日时分秒

    var d = new Date(); ) + "-" + d.getDate() + " " + d.getHours() + ":" + ...

  9. 2016 Multi-University Training Contest 1 总结

    算是组队后第一次打比赛吧. 09题开始就有人过了,看到题目,这不是轮廓线DP的裸题么?!!,一发WA告终,然后发现题目是有改动的.还是太心急了. 然后我读了第一题,是最小生成树求期望距离,我把题意说了 ...

  10. ubuntu13.04安装SenchaArchitect-2.2无法启动的问题

    系统是ubuntukylin-13.04-desktop版本,不知道别的版本有没有这个问题,未测试.SenchaArchitect采用最新版本2.2.2,我安装的是32位的. 具体无法启动的问题如下: ...