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. 0x16 Trie

    这章刷的真带劲 嘿嘿 裸题 #include<cstdio> #include<iostream> #include<cstring> #include<cs ...

  2. asf

    这些日子我一直在写一个实时操作系统内核,已有小成了,等写完我会全部公开,希望能  够为国内IT的发展尽自己一份微薄的力量.最近看到很多学生朋友和我当年一样没有方向  ,所以把我的经历写出来与大家共勉, ...

  3. maven冲突管理及依赖管理实践

    1.“最近获胜策略(nearest wins strategy)”的方式处理依赖冲突 Maven采用“最近获胜策略(nearest wins strategy)”的方式处理依赖冲突,即如果一个项目最终 ...

  4. 知网下载pdf文件的方法

    title: 知网下载pdf文件的方法 toc: false date: 2018-11-02 17:54:43 categories: methods tags: 知网 平时我们使用的是国内版的知网 ...

  5. week5_notebooke1

    大纲: 01 装饰器进阶 02 函数的有效信息 03 可迭代对象.迭代器 04 生成器 列表生成式 生成器表达式 05 内置函数 06 二分查找 01 装饰器进阶 #多个装饰器装饰同一个函数: ## ...

  6. mysql case when then 使用

    建表:create table hank (id int,name varchar(20)); 插入数据:insert into hank values(1,'A');insert into hank ...

  7. JSTL教程 [JSP 标准标记库]

    JSTL教程- - JSP 标准标记库(JSP Standard Tag Library,JSTL)是一个实现 Web 应用程序中常见的通用功能的定制标记库集,这些功能包括迭代和条件判断.数据管理格式 ...

  8. 防范CSRF(三)

    除了可以更改微软默认的cookie的名字外,还可以更改默认的加密方法.继承IAntiForgeryAdditionalDataProvider接口,实现里面的方法即可. 采用的加密方法有加盐和使用时间 ...

  9. day09-3 数据类型总结,深浅拷贝

    目录 数据类型总结,深浅拷贝 存一个值还是多个值 有序 or 无序 可变 or 不可变 浅拷贝和深拷贝的区别(只针对可变类型) 1.拷贝: 3.深拷贝 总结: 数据类型总结,深浅拷贝 存一个值还是多个 ...

  10. Win10内核驱动强制签名,申请沃通 EV代码签名证书

    2016年7月,微软在MSDN宣布从Windows 10的1607版本开始,强制要求所有新的Win10 内核驱动程序,必须获得Windows硬件开发者中心仪表盘门户的数字签名才能在系统中运行.这项政策 ...