模拟

#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的更多相关文章

  1. [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 ...

  2. Time complexity analysis of algorithms

    时间复杂性的计算一般而言,较小的问题所需要的运行时间通常要比较大的问题所需要的时间少.设一个程序P所占用的时间为T,则 T(P)=编译时间+运行时间. 编译时间与实例特征是无关的,且可假设一个编译过的 ...

  3. Cyclomatic complexity

    Cyclomatic Code Complexity was first introduced by Thomas McCabe in 1976. In 1976, Thomas McCabe pub ...

  4. Leetcode: Convert sorted list to binary search tree (No. 109)

    Sept. 22, 2015 学一道算法题, 经常回顾一下. 第二次重温, 决定增加一些图片, 帮助自己记忆. 在网上找他人的资料, 不如自己动手. 把从底向上树的算法搞通俗一些. 先做一个例子: 9 ...

  5. [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 ...

  6. array题目合集

    414. Third Maximum Number 给一个非空的整数数组,找到这个数组中第三大的值,如果不存在,那么返回最大的值.要求时间复杂度为o(n) 例如: Example 1: Input: ...

  7. 【LeetCode】#1 Two Sum

    [Question] Given an array of integers, return indices of the two numbers such that they add up to a ...

  8. 【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 ...

  9. {ICIP2014}{收录论文列表}

    This article come from HEREARS-L1: Learning Tuesday 10:30–12:30; Oral Session; Room: Leonard de Vinc ...

随机推荐

  1. "Debugging not possible in single session mode"

    PLSQL  Developer在测试存储过程,遇到"Debugging not possible in single session mode" 解决办法: 点击菜单栏" ...

  2. inno setup 1

      1.简单脚本 [setup] AppName=Test AppVerName=Test DefaultDirName="d:\setup\app" AppVersion=1.0 ...

  3. ENC28j60以太网芯片驱动程序简介

    ENC28j60以太网芯片驱动程序简介 ENC28J60 驱动开发要点 enc28J60 和 Arduino (1)——ping通你的Arduino MCU51单片机uIP协议栈+ENC28J60网卡 ...

  4. switch case多值匹配

    switch case多值匹配一般有两种情况 1.列举(将所有值列举出来) var n= 3;switch (n){    case 1:     case 2:    case 3:         ...

  5. 转 : 如何用sys as sysdba权限连接数据库进行EXP/IMP

    使用sys as sysdba权限进行EXP/IMP与其它用户稍有不同,详细内容如下(摘自metalink) Applies to: Oracle Server - Enterprise Editio ...

  6. C# Socket的TCP通讯

    Socket的TCP通讯 一. socket的通讯原理 服务器端的步骤如下. (1)建立服务器端的Socket,开始侦听整个网络中的连接请求. (2)当检测到来自客户端的连接请求时,向客户端发送收到连 ...

  7. linux命令:find详解

    Linux中find命令常见用法示例: find path -option [-print] [ -exec -ok command ] {} \; #-print 将查找到的文件输出到标准输出#-e ...

  8. POJ1308 Is It A Tree?

    题目大意:和HDU1272-小希的迷宫题目一样, 如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径 ...

  9. 下拉刷新和上拉加载 Swift

    转载自:http://iyiming.me/blog/2015/07/05/custom-refresh-and-loading/ 关于下拉刷新和上拉加载,项目中一直使用MJRefresh(原先还用过 ...

  10. 查看log的方法

    adb logcat>1.txt adb shell cat /proc/atf_log/atf_log > atf_log 会保存在adb的本地文件. 还有一种是实时读取的方式: adb ...