6 solutions
-
-1
解题报告
撰写人: 许苡键
难度等级
★★☆☆☆
参考程序
#include<bits/stdc++.h> using namespace std; long long a[15][15],h,l,c,r,sum,dx[8]={-1,-1,-1,0,1,1,1,0}; long long dy[8]={-1,0,1,1,1,0,-1,-1}; bool check(int x,int y){ return x>=0&&x<h&&y>=0&&y<l; } int main(){ cin>>h>>l>>c>>r; for(int i=0;i<h;i++) for(int j=0;j<l;j++) cin>>a[i][j]; for(int i=0;i<8;i++){ int nx=c+dx[i],ny=r+dy[i]; if(check(nx,ny))sum+=a[nx][ny]; } cout<<sum; }
Information
- ID
- 292
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- 5
- Tags
- # Submissions
- 71
- Accepted
- 27
- Uploaded By