BNU 51002 BQG's Complexity Analysis
模拟
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=+;
char t1[maxn],t2[maxn];
int g1,g2,h1,h2; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
g1=g2=h1=h2=;
scanf("%s%s",t1,t2); if(t1[]=='n') g1=;
if(t1[]=='^')
{
g1=;
for(int i=;;i++)
{
if(t1[i]>=''&&t1[i]<='') g1=g1*+t1[i]-'';
else break;
}
} int pos=-;
int len=strlen(t1);
for(int i=;t1[i];i++)
{
if(i+<len&&t1[i]=='l'&&t1[i+]=='o'&&t1[i+]=='g'&&t1[i+]=='n')
{
h1=;
pos=i+;
break;
}
}
if(pos!=-)
{
int sum=;
for(int i=pos;i<len;i++)
{
if(t1[i]>=''&&t1[i]<='') sum=sum*+t1[i]-'';
else break;
}
h1=max(h1,sum);
} if(t2[]=='n') g2=;
if(t2[]=='^')
{
g2=;
for(int i=;;i++)
{
if(t2[i]>=''&&t2[i]<='') g2=g2*+t2[i]-'';
else break;
}
} pos=-;
len=strlen(t2);
for(int i=;t2[i];i++)
{
if(i+<len&&t2[i]=='l'&&t2[i+]=='o'&&t2[i+]=='g'&&t2[i+]=='n')
{
h2=;
pos=i+;
break;
}
}
if(pos!=-)
{
int sum=;
for(int i=pos;i<len;i++)
{
if(t2[i]>=''&&t2[i]<='') sum=sum*+t2[i]-'';
else break;
}
h2=max(h2,sum);
} // printf("%d %d\n",g1,h1);
// printf("%d %d\n",g2,h2); if(g1<g2) printf("First\n");
else if(g1>g2) printf("Second\n");
else
{
if(h1<h2) printf("First\n");
else if(h1>h2) printf("Second\n");
else printf("Both\n");
} }
return ;
}
BNU 51002 BQG's Complexity Analysis的更多相关文章
- [Algorithm] Fibonacci Sequence - Anatomy of recursion and space complexity analysis
For Fibonacci Sequence, the space complexity should be the O(logN), which is the height of tree. Che ...
- Time complexity analysis of algorithms
时间复杂性的计算一般而言,较小的问题所需要的运行时间通常要比较大的问题所需要的时间少.设一个程序P所占用的时间为T,则 T(P)=编译时间+运行时间. 编译时间与实例特征是无关的,且可假设一个编译过的 ...
- Cyclomatic complexity
Cyclomatic Code Complexity was first introduced by Thomas McCabe in 1976. In 1976, Thomas McCabe pub ...
- Leetcode: Convert sorted list to binary search tree (No. 109)
Sept. 22, 2015 学一道算法题, 经常回顾一下. 第二次重温, 决定增加一些图片, 帮助自己记忆. 在网上找他人的资料, 不如自己动手. 把从底向上树的算法搞通俗一些. 先做一个例子: 9 ...
- [LeetCode] Product of Array Except Self 除本身之外的数组之积
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...
- array题目合集
414. Third Maximum Number 给一个非空的整数数组,找到这个数组中第三大的值,如果不存在,那么返回最大的值.要求时间复杂度为o(n) 例如: Example 1: Input: ...
- 【LeetCode】#1 Two Sum
[Question] Given an array of integers, return indices of the two numbers such that they add up to a ...
- 【LeetCode】Product of Array Except Self
Product of Array Except Self Given an array of n integers where n > 1, nums, return an array outp ...
- {ICIP2014}{收录论文列表}
This article come from HEREARS-L1: Learning Tuesday 10:30–12:30; Oral Session; Room: Leonard de Vinc ...
随机推荐
- Ubuntu DNS bind9 配置
下面的配置就是实现解析test.zp.com到不同的IP地址 安装dns server软件包$ apt-get install bind9 配置dns配置文件的路径在/etc/bind路径下面添加一个 ...
- listview前几个item怎么不停加载
在加载前几个item的时候,listview有个Adapter,里面的getView方法会被调用好几遍.原因可能有两种: 1.listview在布局文件里高度写成了wrap_content <? ...
- 多个dropdownlist只有第一个能选中,其他选不中之我见
前段时间遇到这个问题,发现在页面中的源代码已经显示selected=“selected" 可是还是选中的第一项,试过很多办法,都不行,最后只好靠js来解决了,获取所有的dropdownlis ...
- C#操作SQLite 报错 (Attempt to write a read-only database)
解决办法:找到SQLite数据库所在的文件夹,单击右键,属性->安全,为Users用户组添加写入权限.
- event小解
首先是一个小例子: <input type="text" onclick="a(event)"/> function a(event){ con ...
- NSArray或NSDictionary中汉字输出
1.问题: NSArray *array = [NSArray arrayWithObjects:@"我",@"在",@"鼓楼", nil] ...
- 华哥倒酒<区间标记,二分>
题目链接 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; t ...
- Break on _NSLockError() to debug.
*** -[NSCondition dealloc]: condition (<NSCondition: 0x1039a450> '(null)') deallocated while s ...
- GameUnity 2.0 文档(三) 纸片人八方向
DirectSprite类 有别于 上篇文档出现的 AnimationSprite类 (从头播放到尾) 这个类根据 path的图,如果是 8*8 64个图 八方向,可以设置长宽和 角度 角度 代表 8 ...
- GameUnity 2.0 发布倒计时
万众期待的 gameunity 网络游戏框架 已经完成了,现在在最后的检验调试阶段. 因为版本 改动非常之大,所以 版本号 从0.2版本 改成 2.0版本. gameunity事件部分,一如既往保持高 ...