HDU 4972 Bisharp and Charizard 想法题
Bisharp and Charizard
Time Limit: 1 Sec Memory Limit: 256 MB
Description
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
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
Sample Input
2 2 2 3 4 1 3 5 7
Sample Output
题意
:篮球比赛有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 想法题的更多相关文章
- HDU - 5806 NanoApe Loves Sequence Ⅱ 想法题
http://acm.hdu.edu.cn/showproblem.php?pid=5806 题意:给你一个n元素序列,求第k大的数大于等于m的子序列的个数. 题解:题目要求很奇怪,很多头绪但写不出, ...
- HDU - 5969 最大的位或 想法题
http://acm.hdu.edu.cn/showproblem.php?pid=5969 (合肥)区域赛签到题...orz 题意:给你l,r,求x|y的max,x,y满足l<=x<=y ...
- HDU 5632 Rikka with Array [想法题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5632 ------------------------------------------------ ...
- HDU 4638 树状数组 想法题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4638 解题思路: 题意为询问一段区间里的数能组成多少段连续的数.先考虑从左往右一个数一个数添加,考虑当 ...
- 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. ...
- HDU 5635 ——LCP Array ——————【想法题】
LCP Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- hdu 5063 不错的小想法题(逆向处理操作)
题意: 刚开始的时候给你一个序列,长度为n,分别为a[1]=1,a[2]=2,a[3]=3,a[4]=4...a[n]=n,然后有4种操作如下: Type1: O 1 call fun1( ...
- CodeForces 111B - Petya and Divisors 统计..想法题
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
随机推荐
- Request请求总结
Request.ServerVariables["Url"] 返回服务器地址 Request.ServerVariables["Path_Info"] 客户端提 ...
- socket基本
fd_set用法: http://blog.sina.com.cn/s/blog_5c8d13830100erzs.htm socket连接: lpszHost="127.0.0.1&quo ...
- android edittext 去边框
EditText的background属性设置为@null就搞定了:android:background="@null" style属性倒是可加可不加 附原文:@SlumberMa ...
- Lucene4.3开发之分词器总结
Lucene4.3开发之分词器总结 http://java.chinaitlab.com/tools/940011.html
- svn提交时强制添加注释 (转)
SVN提交时,如果没有注释,在查阅历史时,会非常不方便.因此我们需要有一个让程序员提交代码时,强制添加注释的规则.下面看看在SVN中怎么实现. 1. 推荐使用VisualSVN作为服务端(免费下载地址 ...
- Sum Root to Leaf Numbers
int sumNumbers(TreeNode *root) { ); } int dfs(TreeNode *root, int sum) { ; if (root->left == null ...
- PHPStorm+Wamp+Xdebug+Windows7调试代码
Wamp 集成环境 PHPStorm+Xdebug 调试代码 2013.04.16 花了两个小时时间终于 , 配置成功了 ! 我的开发环境如下 , 其它环境也可以参考我的配置 开发环境 : Windo ...
- c++ builder xe2 (Embarcadero rad studio) 远程调试 同样适用于 delphi 远程调试 教程
转载:http://www.cnblogs.com/zhangdongsheng/p/3411056.html 每次要远程调试的时候都要看半天的xe2英文帮助文档,今天正好有点时间,把它写下来. 一. ...
- XPath学习:轴(3)——descendant
XPath 是一门在 XML 文档中查找信息的语言.XPath 可用来在 XML 文档中对元素和属性进行遍历. XPath 是 W3C XSLT 标准的主要元素,并且 XQuery 和 XPointe ...
- 不使用arc功能时的编译参数 –fno-objc-arc
用一些老代码时,里面总有release调用,你需要用上这个标记,不使用arc功能编译代码.我总记不住具体写法,做个记录.