http://acm.nyist.net/JudgeOnline/problem.php?pid=590
#include<stdio.h> int a[1010]; int main() { int n,m,i,j,sum,temp; while(~scanf("%d%d",&n,&m)) { sum=0; for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) { for(j=i,temp=0;temp<m&&j<n;j++) temp += a[j]; if(m == temp) sum++; } printf("%d\n",sum); } return 0; }
时间: 2024-10-13 02:31:44