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 ...
随机推荐
- Oracle中清除BIN$开头的垃圾表的解决办法
10g的新特性flashback闪回区 在10g中bin开头表示已经删除的放在回收站的表,oracle在删除表时并没有彻底的删除,而是把表放入回收站!purge recyclebin清空回收站即可. ...
- Ugly Problem
Ugly Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Spec ...
- WPF(x:Null 使用)
<Window x:Class="TestOfNull.MainWindow" xmlns="http://schemas.microsoft.com/winfx/ ...
- weak和assign区别
weak比assign多了一个功能,当对象消失后自动把指针变成nil haofanazenmeban[4002:406590] controller:<SecondViewController: ...
- 编译使用tinyxml
环境: win7 32位旗舰版,VS2010,tinyxml_2_6_2版本 1.下载tinyxml,并解压到tinyxml文件夹下 2.生成动态链接库 原生的Tinyxml只支持静态库(没有在.h文 ...
- HDU1372:Knight Moves(BFS)
Knight Moves Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- cocos2d-x3.x Vector
auto sp0 = Sprite::create(); sp0->setTag(); auto sp1 = Sprite::create(); sp1->setTag(); //这里使用 ...
- R语言——绘图函数深入学习
利用R自带数据集 通过data()函数可以查看R自带数据集. > data() 返回以下结果,每一条记录都是一个数据,键入相应的数据名称可以查看具体信息. Data sets in packag ...
- 【python之路10】python实例练习
#!usr/bin/env python # -*- coding:utf-8 -*- # 一.元素分类 # # 有如下值集合 [11,22,33,44,55,66,77,88,99,90...], ...
- php csv操作
csv的写入数据: $data = array( array('qq号','登录时间','名称'), array('123456','2012-08-21 15:21:10'.chr(1),'我是来测 ...