Description
The 36th ACM match was hosted in Chengdu in 2011 Nov 4. There is an interesting rule in ACM match that once you solve a problem, you'll get a balloon.
To simplify these names, we just name these teams S1, S2, S3 ... SN.
We want to know how many balloons they get between team Si and Sj (including Si and Sj). We may ask many times. It is too boring to count every time.
Since you are a programmer, can you write a program to solve it?
Input
First is an integer N (1 <= N <= 140) indicates the number of schools.
Followed with an integer M (1 <= M <= 50000) indicates the number of operations.
There are two kinds of operations.
AC X
Means team SX solve a problem and will get a balloon.
COUNT X Y
Means count balloons of team between SX and SY
Output
For each operation "COUNT X Y" output the number you count
Sample Input
5 4
AC 1
COUNT 1 3
AC 2
COUNT 1 3
Sample Output
1
2
我的程序:
#include
#include
#include
using namespace std;
int main()
{
int b,a;
scanf("%d%d",&b,&a);
int *c=new int[b];
for(int j=0;j
{
c[j]=0;
}
while(a--)
{
string d;
int g,p,f;
cin>>d;
if(d=="AC")
{
scanf("%d",&g);
c[g-1]++;
}else if(d=="COUNT")
{
scanf("%d%d",&p,&f);
int sum=0;
for(int i=p-1;i<f;i++)
{
sum+=c[i];
}
printf("%d\n",sum);
}
}
return 0;
}