zzuoj--10399--Turing equation(模拟)
Turing equation
Time Limit: 1 Sec Memory Limit:
128 MB
Submit: 152 Solved: 85
[Submit][Status][Web
Board]
Description
the early days of computer science. Joe Stoy, in his (by the way excellent) book "Denotational Semantics", tells following story:
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
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
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(模拟)的更多相关文章
- 第七届河南省赛F.Turing equation(模拟)
10399: F.Turing equation Time Limit: 1 Sec Memory Limit: 128 MB Submit: 151 Solved: 84 [Submit][St ...
- Turing equation
Turing equation 时间限制: 1 Sec 内存限制: 128 MB 题目描述 The fight goes on, whether to store numbers starting w ...
- poj 2572 Hard to Believe, but True!
Hard to Believe, but True! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3537 Accep ...
- 每天一套题打卡|河南省第七届ACM/ICPC
A 海岛争霸 题目:Q次询问,他想知道从岛屿A 到岛屿B 有没有行驶航线,若有的话,所经过的航线,危险程度最小可能是多少. 多源点最短路,用floyd 在松弛更新:g[i][k] < g[i][ ...
- [NOIP10.6模拟赛]2.equation题解--DFS序+线段树
题目链接: 咕 闲扯: 终于在集训中敲出正解(虽然与正解不完全相同),开心QAQ 首先比较巧,这题是\(Ebola\)出的一场模拟赛的一道题的树上强化版,当时还口胡出了那题的题解 然而考场上只得了86 ...
- 基于网格的波动方程模拟(Wave equation on mesh)附源码
波动方程是偏微分方程 (PDE) 里的经典方程,它在物理学中有大量应用并经常用来解释空间中的能量传播.波动方程是一个依赖时间的方程,它解释了系统状态是如何随着时间的推移而发生变化.在下面模拟波动方程时 ...
- Fabricate equation(dfs + 模拟)
Fabricate equation Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Other ...
- UVA 1661 Equation (后缀表达式,表达式树,模拟,实现)
题意:给出一个后缀表达式f(x),最多出现一次x,解方程f(x) = 0. 读取的时候用一个栈保存之前的结点,可以得到一颗二叉树,标记出现'X'的路径,先把没有出现'X'的子树算完,由于读取建树的时候 ...
- [CSP-S模拟测试]:Equation(数学+树状数组)
题目描述 有一棵$n$个点的以$1$为根的树,以及$n$个整数变量$x_i$.树上$i$的父亲是$f_i$,每条边$(i,f_i)$有一个权值$w_i$,表示一个方程$x_i+x_{f_i}=w_i$ ...
随机推荐
- ES 處於“initializing”狀態,此時主節點正在嘗試將分片分配到集群中的數據節點。 如果您看到分片仍處於初始化或未分配狀態太長時間,則可能是您的集群不穩定的警告信號。
指標要點: Cluster status: 如果集群狀態為黃色,則至少有一個副本分片未分配或丟失. 搜索結果仍將完成,但如果更多的分片消失,您可能會丟失數據. 紅色的群集狀態表示至少有一個主分片丟失, ...
- 在centos上面开机自启动某个程序
Systemd 是 Linux 系统工具,用来启动守护进程,已成为大多数发行版的标准配置.可以通过 systemctl --version 命令来查看使用的版本 常用命令 # 立即启动一个服务 $ s ...
- BZOJ 1806 DP
思路: f[i][a][b][c][d] 表示在第i天 昨天1矿吃的是a 前天1矿吃的是b 昨天2矿吃的是c 前天2矿吃的是d 的最优解 暴力转移 哦 需要优化一下空间- 变成i%2 就好了 //By ...
- 微信小程序 | 小程序的转发问题
1.配置小程序页面静态转发信息 关于小程序转发问题,文档 在 page 页面填加了该监听函数,会在小程序右上角 ... 菜单中显示“转发”按钮: 监听函数需要 return {} 其中的内容配置转发信 ...
- (转载)Android项目实战(二十八):Zxing二维码实现及优化
Android项目实战(二十八):Zxing二维码实现及优化 前言: 多年之前接触过zxing实现二维码,没想到今日项目中再此使用竟然使用的还是zxing,百度之,竟是如此牛的玩意. 当然,项目中 ...
- SQL Server死锁排查
1. 死锁原理 根据操作系统中的定义:死锁是指在一组进程中的各个进程均占有不会释放的资源,但因互相申请被其他进程所站用不会释放的资源而处于的一种永久等待状态. 死锁的四个必要条件:互斥条件(Mutua ...
- 基于vue项目的js工具方法汇总
以下是个人过去一年在vue项目的开发过程中经常会用到的一些公共方法,在此进行汇总,方便以后及有需要的朋友查看~ let util = {}; /** * @description 日期格式化 * @p ...
- 新物理AI将可能成为量子计算革命的关键
新物理AI将可能成为量子计算革命的关键 据外媒报道,量子计算无疑是现在最令人兴奋的技术之一,但它的量子物理基础却让它成为了一个令人讨厌的概念理解甚至很难再展开其他事情.然而,最近物理学研究的一项突破可 ...
- 记一次mybatis<if>标签的问题
前言 到底还是没理解清楚的锅~~~~搞了好久...啊啊啊啊 错误: There is no getter for property named 'name' in 'class java.lang.L ...
- leetcode525. 连续数组 python
给定一个二进制数组, 找到含有相同数量的 0 和 1 的最长连续子数组. 示例 1: 输入: [0,1] 输出: 2 说明: [0, 1] 是具有相同数量0和1的最长连续子数组. 示例 2: 输入: ...