Bisharp and Charizard

Time Limit: 1 Sec  Memory Limit: 256 MB

Description

Dragon is watching NBA. He loves James and Miami Heat.

Here's an introduction of basketball game:http://en.wikipedia.org/wiki/Basketball. However the game in Dragon's version is much easier:

"There's two teams fight for the winner. The only way to gain scores is to throw the basketball into the basket. Each time after throwing into the basket, the score gained by the team is 1, 2 or 3. However due to the uncertain factors in the game, it’s hard to predict which team will get the next goal".

Dragon is a crazy fan of Miami Heat so that after each throw, he will write down the difference between two team's score regardless of which team keeping ahead. For example, if Heat's score is 15 and the opposite team's score is 20, Dragon will write down 5. On the contrary, if Heat has 20 points and the opposite team has 15 points, Dragon will still write down 5.

Several days after the game, Dragon finds out the paper with his record, but he forgets the result of the game. It's also fun to look though the differences without knowing who lead the game, for there are so many uncertain! Dragon loves uncertain, and he wants to know how many results could the game has gone? 

input

The first line of input contains only one integer T, the number of test cases. Following T blocks, each block describe one test case.

For each test case, the first line contains only one integer N(N<=100000), which means the number of records on the paper. Then there comes a line with N integers (a 1, a 2, a 3, ... , a n). a i means the number of i-th record.

 

ouput

Each output should occupy one line. Each line should start with "Case #i: ", with i implying the case number. Then for each case just puts an integer, implying the number of result could the game has gone.
 
 

Sample Input

2 2 2 3 4 1 3 5 7

Sample Output

Case #1: 2 Case #2: 2

题意  

:篮球比赛有1、2、3分球  现给出两队的分差序列(5:3 分差2  3:5分差也是2)  问有多少种可能的比分

题解:

比较简单的想法题  可以类一张表“从分差x到分差y一共有几种情况”  很容易发现只有1->2和2->1的时候会多一种情况  其他均是一种  所以只需要统计这种特殊分差即可  注意一下最后结果要不要乘2  如果最后分差是0就不用因为x:x只有一种  但是最后分差不是0就要乘  因为x:y和y:x算两种  还有本题有坑!! 那个SB记分员会把分数记错  所以一旦记错种类数就为0了

代码:

 #include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <typeinfo>
#include <map>
#include <stack>
typedef long long ll;
#define inf 0x7fffffff
using namespace std;
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//************************************************************************************** int main()
{ int T=read();
int oo=;
while(T--)
{ int n,a[];
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
}
a[]=;
int flag=;
int ans=;
for(int i=;i<=n;i++)
{
if(abs(a[i]-a[i-])>||(a[i]!=&&a[i]==a[i-]))
{
flag=;
break;
}
if((a[i]==&&a[i-]==)||(a[i]==&&a[i-]==))ans++;
}
printf("Case #%d: ",oo++);
if(flag){
printf("0\n");
}
else {
if(a[n]==){
printf("%d\n",ans);
}
else printf("%d\n",ans*);
}
}
return ;
}

HDU 4972 Bisharp and Charizard 想法题的更多相关文章

  1. HDU - 5806 NanoApe Loves Sequence Ⅱ 想法题

    http://acm.hdu.edu.cn/showproblem.php?pid=5806 题意:给你一个n元素序列,求第k大的数大于等于m的子序列的个数. 题解:题目要求很奇怪,很多头绪但写不出, ...

  2. HDU - 5969 最大的位或 想法题

    http://acm.hdu.edu.cn/showproblem.php?pid=5969 (合肥)区域赛签到题...orz 题意:给你l,r,求x|y的max,x,y满足l<=x<=y ...

  3. HDU 5632 Rikka with Array [想法题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5632 ------------------------------------------------ ...

  4. HDU 4638 树状数组 想法题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4638 解题思路: 题意为询问一段区间里的数能组成多少段连续的数.先考虑从左往右一个数一个数添加,考虑当 ...

  5. HDU 5908 Abelian Period(暴力+想法题)

    传送门 Description Let S be a number string, and occ(S,x) means the times that number x occurs in S. i. ...

  6. HDU 5635 ——LCP Array ——————【想法题】

    LCP Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  7. hdu 5063 不错的小想法题(逆向处理操作)

    题意:       刚开始的时候给你一个序列,长度为n,分别为a[1]=1,a[2]=2,a[3]=3,a[4]=4...a[n]=n,然后有4种操作如下: Type1: O 1 call fun1( ...

  8. CodeForces 111B - Petya and Divisors 统计..想法题

    找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...

  9. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

随机推荐

  1. JSP 内置对象(request response session application out pageContext)

    request对象  javax.servlet.http.HttpServletRequest接口的实例 request.setCharacterEncoding("utf-8" ...

  2. 深入理解Java中的继承

    对于面向对象的程序设计而言,每一个程序员都应该去了解Java中的封装,继承和多态,那么我今天来说的主要是以继承为核心的主题. 一.关于对继承的理解. 继承是面向对象的三大特性之一,是java中实现代码 ...

  3. HttpWatch详解

    一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...

  4. [Effective JavaScript 笔记] 第6条:了解分号插入的局限

    分号可以省略 js可以在语句结束不强制加分号.(建议还是添加,不添加分号往往会出现不易发现的BUG) function Point(x,y){ this.x=x||0; this.y=y||0; } ...

  5. TCP协议漏洞影响大量Linux设备

    导读 本周三在得州奥斯丁举行的 USENIX 安全研讨会上,加州大学河滨分校研究生 Yue Cao 将报告一个严重的TCP协议边信道漏洞(PDF),该漏洞允许攻击者远程劫持任意两主机之间的会话.该漏洞 ...

  6. C#关键字base

    例子: public CustomStroke(SharpType type) :base() { this.type = type; } 这里的CustomStroke继承与基类Stroke类,用关 ...

  7. Maven使用常见问题整理

    Maven使用常见问题整理  1.更新eclipse的classpath加入新依赖  1.在dependencyManagement里面加入包括版本在内的依赖信息,如:   <dependenc ...

  8. FFT(1)

    FFT Complex struct complex{ double re,im; complex(double r,double i){re=r,im=i;} complex(){re=0.0,im ...

  9. CSS用类选择器在本页写样式

    <title>静夜思</title><style type="text/css">p{color:#ff0000; font-size:24px ...

  10. 【转】如何调试bash脚本

    本文转自:http://coolshell.cn/articles/1379.html Bash 是Linux操作系统的默认Shell脚本.Shell是用来处理操作系统和用户交互的一个程序.Shell ...