bnuoj 29368 Check the Identity(栈)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29368
【题解】:模拟,然后对x,进行枚举,看是否所有都满足条件
【code】:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <list>
#include <string>
#include <string.h> using namespace std; double stack[];
int s_cnt; double fabs(double a)
{
return a>?a:-a;
} char op[];
int len; int checkRight(double x)
{
int i;
s_cnt = -;
for(i=;i<len;i++)
{
char ch = op[i];
if(ch=='x')
{
s_cnt++;
stack[s_cnt] = x;
}
else if(ch=='s')
{
stack[s_cnt] = sin(stack[s_cnt]);
}
else if(ch=='c')
{
stack[s_cnt] = cos(stack[s_cnt]);
}
else if(ch=='t')
{
stack[s_cnt] = tan(stack[s_cnt]);
}
else if(ch=='-')
{
stack[s_cnt-] = stack[s_cnt-] - stack[s_cnt];
s_cnt--;
}
else if(ch=='+')
{
stack[s_cnt-] = stack[s_cnt]+stack[s_cnt-];
s_cnt--;
}
else if(ch=='*')
{
stack[s_cnt-] = stack[s_cnt]*stack[s_cnt-];
s_cnt--;
}
}
if(fabs(stack[])>1e-) return ;
return ;
} int main()
{
int t,cas=;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int i;
char str[];
s_cnt = -;
len = ;
for(i=;i<n;i++)
{
scanf("%s",str);
op[len] = str[];
len++;
}
double l=-,r=;
double step = 4.0/;
int flag=;
for(;l<=r;l++)
{
if(!checkRight(l))
{
flag=;
break;
}
}
printf("Case %d: ",cas++);
if(!flag)
{
puts("Yes");
}
else
{
puts("No");
}
}
return ;
}
bnuoj 29368 Check the Identity(栈)的更多相关文章
- BNU29368:Check the Identity(栈)
Just determine whether an algebraic expression can always simplify to zero. Input The first line con ...
- 【ASP.NET Identity系列教程(二)】运用ASP.NET Identity
注:本文是[ASP.NET Identity系列教程]的第二篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...
- ASP.NET Identity 二 (转载)
来源:http://www.cnblogs.com/r01cn/p/5180892.html#undefined 推荐看原文,这里转载是怕好文章消失了. 注:本文是[ASP.NET Identity系 ...
- ASP.NET Identity系列教程-3【运用ASP.NET Identity】
https://www.cnblogs.com/r01cn/p/5180892.html 14 运用ASP.NET Identity In this chapter, I show you how t ...
- 关于refs/for/ 和refs/heads/
1. 这个不是git的规则,而是gerrit的规则, 2. Branches, remote-tracking branches, and tags等等都是对commite的引用(re ...
- CLR via C# 3rd - 05 - Primitive, Reference, and Value Types
1. Primitive Types Any data types the compiler directly supports are called primitive types. ...
- [转]Installing SharePoint 2013 on Windows Server 2012 R2
转自:http://www.avivroth.com/2013/07/09/installing-sharepoint-2013-on-windows-server-2012-r2-preview/ ...
- 《Effective C#》:区别和认识四个判等函数
.Net有四个判等函数?不少人看到这个标题,会对此感到怀疑.事实上确是如此,.Net提供了ReferenceEquals.静态Equals,具体类型的Equals以及==操作符这四个判等函数.但是这四 ...
- 【转】区别和认识.Net四个判等函数
原文地址:不详 .Net有四个判等函数?不少人看到这个标题,会对此感到怀疑.事实上确是如此,.Net提供了ReferenceEquals.静态Equals,具体类型的Equals以及==操作符这四个判 ...
随机推荐
- hdu 2665 划分树
思路:裸的划分树 #include<iostream> #include<algorithm> #include<cstring> #include<cstd ...
- Linux 命令 - at: 在指定的时间执行任务
在指定的时间执行任务. 命令格式 at [-V] [-q queue] [-f file] [-mldbv] TIMEat [-V] [-q queue] [-f file] [-mldbv] -t ...
- asp网站发布步骤总结
1.在VS2012中打开索要发布的网站,初始页可重命名为index.html或default.apx. 2.点击 生成>生成“网站”,然后“发布网站”. 3.进行发布设置: (1 配置文件 ( ...
- 备忘====[HttpPost]和[AcceptVerbs(HttpVerbs.Post)]区别
1.共同点:[HttpPost]和[AcceptVerbs(HttpVerbs.Post)]都是只接受POST请求过来的数据. 2.不同点:在MVC中如果想一个action既可以回应POST请求也可以 ...
- javascrip笔记——图片加载
var t_img; // 定时器 var isLoad = true; // 控制变量 // 判断图片加载状况,加载完成后回调 isImgLoad(function(){ // 加载完成 }); / ...
- 《C#高级编程》
<C#高级编程>是一本真正的C#技术"字典",长达36章.1200页的内容-涵盖了C#..NET各个方面的基础内容. 当然这本书我没有真正的看过一遍,只是在需要的时候才 ...
- TIMAC 学习笔记(二)
昨天大体上熟悉了TIMAC自带的CC2530的示范例程,今天先从演示抓包入手,分析四种不同的配置工程在空中传输的差异.随后,会按照扫描.组网.入网等MAC层接口函数入手,结合IEEE 802.15.4 ...
- 第三章 用SDK编译出第一个在Linux下的软件界面
第三章 用SDK编译出第一个在Linux下的软件界面 先创建一个工程目录“mkdir project1”,进入目录,创建main.cpp文件,编写代码如下: 代码内容暂时可以先不理解,先让程序跑起来再 ...
- const和#define的区别
在刷题的时候经常遇到定义全局常量我一般都是用#define(可能是因为很少接触const的原因) 在昨天做到51nod1082时照常暴力用#define定义最大.可是提交超时..... 后来看他人写的 ...
- http返回状态代码及含义
“100″ : Continue(继续) 初始的请求已经接受,客户应当继续发送请求的其余部分.(HTTP 1.1新) “101″ : Switching Protocols(切换协议) 请求者已要求服 ...