HDU
来源:互联网 发布:矩阵的迹是什么 编辑:程序博客网 时间:2024/06/05 20:22
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?
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?
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.
222 341 3 5 7
Case #1: 2Case #2: 2
分差从1变到2挥着从2变到1的时候结果才有变化。分差1变到1是可以的,其他连续两个相同的数是不行的。还有第一个数不能是0.如果最后一个数非0,结果要乘2.
int a[100000+10];int main(){ ios::sync_with_stdio(false); int T; cin>>T; int cas=1; while(T--) { int n; cin>>n; memset(a,0,sizeof(a)); for(int i=1;i<=n;i++) { cin>>a[i]; } ll ans=1; for(int i=1;i<=n;i++) { if(a[i]==1 && a[i-1]==2)ans++; if(a[i]==2 && a[i-1]==1)ans++; if(a[i]-a[i-1]>3 || a[i-1]-a[i]>3) { ans=0; break; } if(a[i]==a[i-1] && a[i]!=1) { ans=0; break; } if(a[1]==0) { ans=0; break; } } if(a[n])ans*=2; cout<<"Case #"<<cas++<<": "<<ans<<endl; } return 0;}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- jQuery Validation使用教程
- HDU-1863 畅通工程——并查集最小生成树Kruskal
- 二维数组解决杨辉三角问题
- Frida官方手册
- SpringCloud服务注册中心比较:Consul vs Zookeeper vs Etcd vs Eureka
- HDU
- 2017年10月份上海拍牌 最后20秒发生了什么!
- 笔记:sublime text 安装Package Control方法。
- python 新建txt,并写入第一行title,将数据写入新txt
- Session的序列化和反序列化
- 文章标题 input 单选获取文本内容
- JVM系列(一):自己编译jdk遇到的一些坑
- 新安装ubuntu16.04无法联网的问题
- Binary Search:35. Search Insert Position