C - Stripe(注意超时)
来源:互联网 发布:电脑屏幕调节软件 编辑:程序博客网 时间:2024/05/29 17:12
点击打开链接
C - StripeTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmitStatusDescriptionOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece, and each piece contains positive integer amount of squares. Would you help Bob solve this problem?InputThe first input line contains integer n (1 ≤ n ≤ 105) — amount of squares in the stripe. The second line contains n space-separated numbers — they are the numbers written in the squares of the stripe. These numbers are integer and do not exceed 10000 in absolute value.OutputOutput the amount of ways to cut the stripe into two non-empty pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece. Don't forget that it's allowed to cut the stripe along the squares' borders only.Sample InputInput91 5 -6 7 9 -16 0 -2 2Output3Input31 1 1Output0Input20 0Output1
2.代码:
#include<stdio.h>int b[100005];int c[100005];int a[100005];int main(){ int n; scanf("%d",&n); b[0]=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); b[i]=b[i-1]+a[i]; } for(int j=n;j>=1;j--) { c[j]=c[j+1]+a[j]; } int ans=0; for(int i=1;i<n;i++) { if(b[i]==c[i+1]) ans++; } printf("%d\n",ans); return 0;}/*91 5 -6 7 9 -16 0 -2 2*/
- C - Stripe(注意超时)
- C - Stripe ____cf
- CodeForces 18C - Stripe
- codeforces C. Color Stripe
- CF 18C Stripe
- CodeForces 219C Color Stripe
- Color Stripe--codeForces 219C
- codeforces 219C Color Stripe
- CF 21C Stripe 2
- 219C - Color Stripe-模拟
- CodeForces 21 C Stripe 2
- codeforces 219C C. Color Stripe(dp)
- CodeForces 21C Stripe 2 (简单题)
- CodeForces 18C Stripe (简单题)
- CodeForces 21C Stripe 2 构造题
- CodeForces 219C Color Stripe (贪心)
- codeforces 219C Color Stripe(贪心)
- codeforces - 18C - Stripe(练习)
- CD 唱片图形显示
- Memcache分组和同步机制的实现
- C#學習筆記之數組操作
- MySQL 数据库中文乱码
- C 标准库 errno.h
- C - Stripe(注意超时)
- AIX下的MPIO、RDAC、SDDPCM多路径软件操作
- java在ACM竞赛中的使用
- Core Java (八) Java中的代码点与代码单元
- 使用位运算节省计算
- IBM B24交换机光信号强度查看
- B - Platforms(注意处理步跳,超时)
- ubuntu 五笔输入法安装
- Java 的函数 调用