| 比赛 | 
    20110728 | 
    评测结果 | 
    AATEEEEEEE | 
    | 题目名称 | 
    蝗灾 | 
    最终得分 | 
    20 | 
    | 用户昵称 | 
    donny | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2011-07-28 08:41:20 | 
显示代码纯文本
#include <iostream>
#include <fstream>
using namespace std;
int a[2001][2001],i,j,k,l;
int m,n,x,y,p,q;
int main()
{
	ifstream fin("locust.in");
	ofstream fout("locust.out");
	
	fin>>m>>n;
	
	for (i=1;i<=n;i++)
	{
		fin>>l;
		if (l==1)
		{
			fin>>x>>y>>q;
			for (j=x;j<=m;j++)
				for (k=y;k<=m;k++)
					a[j][k]+=q;
		}
		else
		{
			fin>>x>>y>>p>>q;
			fout<<a[p][q]-a[p][y-1]-a[x-1][q]+a[x-1][y-1]<<endl;
		}
	}
	
	fin.close();
	fout.close();
	return 0;
	
}