Turing equation

Time Limit: 1 Sec  Memory Limit:
128 MB

Submit: 152  Solved: 85

[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;
if(ans[0]+ans[1]==ans[2])
puts("TRUE");
else puts("FALSE");
}
return 0;
}

zzuoj--10399--Turing equation(模拟)的更多相关文章

  1. 第七届河南省赛F.Turing equation(模拟)

    10399: F.Turing equation Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 151  Solved: 84 [Submit][St ...

  2. Turing equation

    Turing equation 时间限制: 1 Sec 内存限制: 128 MB 题目描述 The fight goes on, whether to store numbers starting w ...

  3. poj 2572 Hard to Believe, but True!

    Hard to Believe, but True! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3537   Accep ...

  4. 每天一套题打卡|河南省第七届ACM/ICPC

    A 海岛争霸 题目:Q次询问,他想知道从岛屿A 到岛屿B 有没有行驶航线,若有的话,所经过的航线,危险程度最小可能是多少. 多源点最短路,用floyd 在松弛更新:g[i][k] < g[i][ ...

  5. [NOIP10.6模拟赛]2.equation题解--DFS序+线段树

    题目链接: 咕 闲扯: 终于在集训中敲出正解(虽然与正解不完全相同),开心QAQ 首先比较巧,这题是\(Ebola\)出的一场模拟赛的一道题的树上强化版,当时还口胡出了那题的题解 然而考场上只得了86 ...

  6. 基于网格的波动方程模拟(Wave equation on mesh)附源码

    波动方程是偏微分方程 (PDE) 里的经典方程,它在物理学中有大量应用并经常用来解释空间中的能量传播.波动方程是一个依赖时间的方程,它解释了系统状态是如何随着时间的推移而发生变化.在下面模拟波动方程时 ...

  7. Fabricate equation(dfs + 模拟)

    Fabricate equation Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Other ...

  8. UVA 1661 Equation (后缀表达式,表达式树,模拟,实现)

    题意:给出一个后缀表达式f(x),最多出现一次x,解方程f(x) = 0. 读取的时候用一个栈保存之前的结点,可以得到一颗二叉树,标记出现'X'的路径,先把没有出现'X'的子树算完,由于读取建树的时候 ...

  9. [CSP-S模拟测试]:Equation(数学+树状数组)

    题目描述 有一棵$n$个点的以$1$为根的树,以及$n$个整数变量$x_i$.树上$i$的父亲是$f_i$,每条边$(i,f_i)$有一个权值$w_i$,表示一个方程$x_i+x_{f_i}=w_i$ ...

随机推荐

  1. HDFS 文件格式——SequenceFile RCFile

     HDFS块内行存储的例子  HDFS块内列存储的例子  HDFS块内RCFile方式存储的例子

  2. Docker+ELK搭建

    换了个运行环境,重新搭建一套公司本地内部的ELK,之前也搭过(可访问:https://yanganlin.com/31.html),最近做什么事情都想用Docker,这次也用Docker,还算顺利,没 ...

  3. HDU4920 矩阵乘法

    嗯嗯 就算是水题吧. (缩完行就15行) 题意:两个n*n的矩阵相乘(n<=800),结果对3取模 思路:先对3取模,所以两个矩阵里面会出现很多0,所以可以先枚举一个矩阵,只有当该位置不是0的时 ...

  4. 在 Ubuntu 15.04 上安装 Android Studio(极其简单)

    sudo apt-add-repository ppa:paolorotolo/android-studio sudo apt-get update sudo apt-get install andr ...

  5. Core篇——初探Core配置管理

    文章目录 1.命令行配置 2.Json文件配置 3.配置文件文本至C#对象实例的映射 4.配置文件热更新 5.总结 命令行的配置 我们首先来创建一个.net core 的控制台项目,然后引入.net ...

  6. C++逐行读取文本文件的正确做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 之前写了一个分析huson日志的控制台程序,其中涉及到C++逐行读取文本文件的做法,代码是这样写的: ifstream ...

  7. WebView简单用法

    1.空布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:andr ...

  8. thinkphp5-----模板中函数的使用

    1.在模板中使用php函数 在thinkphp的html中,我们经常会遇到一些变量难以直接从php控制端直接处理,这些变量只有在模板中循环输出的时候处理比较合适,这个时候,我们就要在模板中使用函数 1 ...

  9. ZBrush软件特性之Marker标记调控板

    在ZBrush®中使用Marker标记调控板来记忆物体属性,因此能在任何时间回到标记并使用它给其他物体或改变物体作为参考点. ZBrush软件下载:http://pan.baidu.com/s/1sl ...

  10. Activiti Workflow HelloWorld 示例与测试环境搭建

    作者:Rock 出处:http://www.ecmkit.com/zh-hans/2012/03/21/activiti-workflow-hell Activiti Workflow HelloWo ...