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. c11---位运算相关

    // // main.c // 03-原码反码补码 #include <stdio.h> int main(int argc, const char * argv[]) { // int占 ...

  2. 使用神经网络-垃圾邮件检测-LSTM或者CNN(一维卷积)效果都不错【代码有问题,pass】

    from sklearn.feature_extraction.text import CountVectorizer import os from sklearn.naive_bayes impor ...

  3. 对ajax和jsp渲染的一些感想

    一个多月来,也算是做了两个javaweb的项目,但是对于用哪种方式渲染页面一直有些抉择不定,第一个项目用的ajax,发现各种对htmlDom节点的操作十分的繁琐,需要找到数据填充的节点并添加id值,引 ...

  4. [转]C#多线程和线程池

    鸣谢原文:http://www.cnblogs.com/wwj1992/p/5976096.html 1.概念  1.0 线程的和进程的关系以及优缺点 windows系统是一个多线程的操作系统.一个程 ...

  5. windows phone 页面主题设计

    达到如图这个效果: 1.保证状态栏背景色与主题栏颜色相同需设置状态栏的透明度,代码如下: shell:SystemTray.IsVisible="True" shell:Syste ...

  6. ddk安装失败后的处理

    7600.16385.1版本的DDK,在xp的本上死活按不上,怎么办呢?自己就把其他机器上安装的DDK目录,拷贝过来. 怎么建编译环境呢? 查看x86 Checked Build Environmen ...

  7. Activiti Modeler 5.22.0整合到Spring项目

    转载 https://blog.csdn.net/u010411264/article/details/71480354

  8. shell编程-1.字符截取命令-列截取cut

  9. Unity "Build failed : Asset is marked as don't save " 解决方案

    编译到Android时失败,是字体的原因: -- -- 摘自官方论坛排第二但点赞第一的回答. http://answers.unity3d.com/questions/363963/build-fai ...

  10. JQuery中text(),html(),val()的区别

    这3个都是jquery类库中的语法,分别是: text():获取或者改变指定元素的文本: html():获取或改变指定元素的html元素以及文本: val():获取或者改变指定元素的value值(一般 ...