uva 983 - Localized Summing for Blurring Solution



#include<iostream>

using namespace std;

int arr[1005][1005],sum[1005][1005];

int main(){
freopen("test.txt","r",stdin);
int i,j,k,m,n,temp;
unsigned long long val;
bool flag=false;
while(cin>>n>>m){
if(flag)
cout<<endl;
flag=true;

for(i=n-1;i>=0;i--)
for(j=0;j<n;j++)
cin>>arr[i][j];
sum[0][0]=0;
for(i=0;i<m;i++)
for(j=0;j<m;j++)
sum[0][0]+=arr[i][j];
val=sum[0][0];

for(j=1;j<=n-m;j++){
temp=sum[0][j-1];
for(i=0;i<m;i++){
temp=temp-arr[i][j-1]+arr[i][j+m-1];
}
sum[0][j]=temp;
val=val+temp;
}

for(i=1;i<=n-m;i++){
for(j=0;j<=n-m;j++){
temp=sum[i-1][j];
for(k=j;k<j+m;k++){
temp=temp-arr[i-1][k]+arr[i+m-1][k];
}
sum[i][j]=temp;
val=val+temp;
}
}

for(i=n-m;i>=0;i--)
for(j=0;j<=n-m;j++)
cout<<sum[i][j]<<endl;

cout<<val<<endl;
}
return 0;
}

Comments

  1. What does the total bet mean? - Sporting 100
    The total bet means the bettor is placing a single bet on all outcomes of a football match as the result 토토사이트 of a football match changes.

    ReplyDelete

Post a Comment

Popular posts from this blog

uva 679 - Dropping Balls Solution

uva 481 - What Goes Up Solution

uva-10077 Solution --- The Stern-Brocot Number System