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 ...
随机推荐
- isset函数
isset (PHP 4, PHP 5) isset — 检测变量是否设置 检测变量是否设置,并且不是 NULL. 如果 var 存在并且值不是 NULL 则返回 TRUE,否则返回 FALSE. $ ...
- Redis和Memcached的区别【转】
如果简单地比较Redis与Memcached的区别,大多数都会得到以下观点:1 Redis不仅仅支持简单的k/v类型的数据,同时还提供list,set,hash等数据结构的存储.2 Redis支持数据 ...
- 个人linux简单笔记,随时更新
vim显示行数 :set nu 查找文件 find /home -name config.txt 重命名文件或者文件夹 mv a b centos中phpize的安装 yum install php- ...
- mongodb启动
MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可护展的高性能数据存储解决方案.MongoDB是一款分布式文档数据库,支持类似关型数据库的主从结构,文档以二进制J ...
- anyremote源码分析
XTest 鼠标移动事件. XTestFakeMotionEvent 关于XTest的编程. http://lilydjwg.is-programmer.com/2011/9/21/using-x ...
- 不注册COM组件直接调用接口
本文以COM组件AppTest.dll为例,AppTest.dll中提供了ITest接口,在不使用regsvr32命令向系统注册的情况下创建ITest接口并调用. 一.导入组件或类型库: 在C++中使 ...
- Oracle表和表数据恢复
Oracle数据库表及表数据的恢复 1. 表恢复 对误删的表,只要没有使用 purge 永久删除选项,那么基本上是能从 flashback table 区恢复回来的. 数据表和其中的数据都是可以恢复回 ...
- layer属性
键: 值 描述 下表的属性都是默认值,您可在调用时按需重新配置,他们可帮助你实现各式各样的风格.如是调用: $.layer({键: 值, 键: 值, -}); type: 0 层的类型.0:信息框(默 ...
- 为Android系统内置C可执行程序测试Linux内核驱动程序
在前一篇文章中,我们介绍了如何在Ubuntu上为Android系统编写Linux内核驱动程序.在这个名为hello的Linux内核驱动程序中, 创建三个不同的文件节点来供用户空间访问,分别是传统的设备 ...
- java 基础之概念
1:栈(Stack) 先进后出(邮政模拟例) 2:队列(Queue) 先进先出(排队购票)