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 ...
随机推荐
- process lasso 优化原理
<星际争霸2:虚空之遗>很多玩家的CPU性能并不低,但是在星际2中的表现就总会出现掉帧的情况,那么应该如何提升CPU的性能就成了玩家关注的话题,下面小编就为大家带来星际争霸2虚空之遗cpu ...
- Photoshop 字体
字体类型: 宋体系列:北宋年间 超粗宋.粗宋,大标宋.小标宋/中宋.宋体 黑体系列:建国初期 (当时写标语,识别度高) 超粗黑 大黑/黑体 中等线/细黑 --广告.画册.宣传册 非正规场合 文字工具( ...
- WPF子窗体:ChildWindow
wpf的子窗体选择有很多种,如最常见的是项目新建窗体(Window)作为子窗体 ,或者新建wpf用户控件(UserControl).而其实利用Xceed.Wpf.Toolkit.dll 可以轻松布局如 ...
- Android OpenGL ES(十二):三维坐标系及坐标变换初步 .
OpenGL ES图形库最终的结果是在二维平面上显示3D物体(常称作模型Model)这是因为目前的打部分显示器还只能显示二维图形.但我们在构造3D模型时必须要有空间现象能力,所有对模型的描述还是使用三 ...
- UVA 1193 区间相关(greedy)
input n d 1<=n<=1000 n行坐标xi,yi output 位于x轴扫描器的扫描距离为d,至少要多少个扫描器才能扫描到所有坐标 如果无法扫描完输出-1,否则输出扫描器个数 ...
- cocos2d-x-2.2.6创建工程
1.下载并安装Python,我的版本是2.7.3,不要太高,据说不能用.2.配置环境变量,将Python的安装的根目录加入系统环境变量的Path路径中(不赘述,自行配置)3.配置好之后打开cmd命令行 ...
- try...catch...finally...return的四角恋
java里的try...catch...finally的三角恋关系众多程序员必然是不陌生的.但是他们三者再加上一个return的话,就会难倒一大片人吧.以前就对这个知道这个问题,没系统的总结一下,结果 ...
- UVALive 4992 Jungle Outpost(半平面交)
题意:给你n个塔(点)形成一个顺时针的凸包,敌人可以摧毁任何塔,摧毁后剩下的塔再组成凸包 在开始的凸包内选一点为主塔,保证敌人摧毁尽量多塔时主塔都还在现在的凸包内,求出最多摧毁的塔 题解:这题关键就是 ...
- jquery插件简单的声明方法
(function($){ // 声明插件内容 $.fn.pluginName = function(options){ // 默认插件配置 var ...
- mac编译openssl扩展报错 openssl.c:44:10: fatal error: 'openssl/evp.h' file not found
解决办法 brew link openssl --force 然后 ./configure --with-openssl --with-php-config=/usr/local/php/bin/ph ...