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(栈)的更多相关文章

  1. BNU29368:Check the Identity(栈)

    Just determine whether an algebraic expression can always simplify to zero. Input The first line con ...

  2. 【ASP.NET Identity系列教程(二)】运用ASP.NET Identity

    注:本文是[ASP.NET Identity系列教程]的第二篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...

  3. ASP.NET Identity 二 (转载)

    来源:http://www.cnblogs.com/r01cn/p/5180892.html#undefined 推荐看原文,这里转载是怕好文章消失了. 注:本文是[ASP.NET Identity系 ...

  4. 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 ...

  5. 关于refs/for/ 和refs/heads/

    1.     这个不是git的规则,而是gerrit的规则, 2.     Branches, remote-tracking branches, and tags等等都是对commite的引用(re ...

  6. CLR via C# 3rd - 05 - Primitive, Reference, and Value Types

    1. Primitive Types        Any data types the compiler directly supports are called primitive types. ...

  7. [转]Installing SharePoint 2013 on Windows Server 2012 R2

    转自:http://www.avivroth.com/2013/07/09/installing-sharepoint-2013-on-windows-server-2012-r2-preview/ ...

  8. 《Effective C#》:区别和认识四个判等函数

    .Net有四个判等函数?不少人看到这个标题,会对此感到怀疑.事实上确是如此,.Net提供了ReferenceEquals.静态Equals,具体类型的Equals以及==操作符这四个判等函数.但是这四 ...

  9. 【转】区别和认识.Net四个判等函数

    原文地址:不详 .Net有四个判等函数?不少人看到这个标题,会对此感到怀疑.事实上确是如此,.Net提供了ReferenceEquals.静态Equals,具体类型的Equals以及==操作符这四个判 ...

随机推荐

  1. CSS实现标题超出宽度省略号来表示

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  2. C# winform滚动字幕

    private void timer1_Tick(object sender, EventArgs e)//用Timer来控制滚动速度 { label1.Left -= 2;//设置label1左边缘 ...

  3. CSS之拖拽库2

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or ...

  4. 在WCF中使用Flag Enumerations

      请看MSDN示例: [DataContract][Flags] public enum CarFeatures {     None = 0,     [EnumMember]     AirCo ...

  5. Cocos移植到Android-通过命令行交叉编译打包

    当我们在Windows下使用Visual Studio开发好Win32平台的游戏程序后,我们需要把它们移植到不同的平台上.Cocos2d-x支持很多个平台,然而,我们不可能介绍全部平台的移植.我们总结 ...

  6. Cocos2d-x中__Dictionary容器以及实例介绍

    __Dictionary类在Cocos2d-x 2.x时代它就是CCDictionary类,它是模仿Objective-C中的NSDictionary类而设计的,通过引用计数管理内存.__Dictio ...

  7. 前端性能优化工具--DOM Monster

    当我们开发web应用的时候,性能是一个永远不能回避的问题.其实对于DOM的性能调试也是一个不可或缺的过程.使用DOM monster你只需要添加到你的”书签中“,在任何需要调试的页面点击这个书签,它就 ...

  8. 关键字 extern

    定义:extern可置于变量或者函数前,以表示变量或者函数的定义在别的文件中.编译器会到其他模块中寻找其定义. extern int f(); extern int i; extern关键字   作为 ...

  9. Java多线程(四) 线程池

    一个优秀的软件不会随意的创建.销毁线程,因为创建和销毁线程需要耗费大量的CPU时间以及需要和内存做出大量的交互.因此JDK5提出了使用线程池,让程序员把更多的精力放在业务逻辑上面,弱化对线程的开闭管理 ...

  10. MySQL和Navicat使用总结

    1.给字段设置默认字符值 ALTER TABLE `v_users`MODIFY COLUMN `picture` varchar(50) CHARACTER SET utf8 COLLATE utf ...