helloworldhahaha @ 2024-11-23 15:58:04
#include <iostream>
#include <vector>
using namespace std;
int n,m,X,Y;
vector<vector<int>> maze;
vector<vector<long long int>> dp;
int way1[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,2},{1,-2},{2,-1},{2,1}};
bool isvalid(int x, int y){
return x>=0&&y>=0&&x<=n&&y<=m&&maze[x][y]==0;
}
long long int find(){
for(int i=0;i<=n;i++){
if(maze[i][0]==0) dp[i][0]=1;
}
for(int j=0;j<=m;j++){
if(maze[0][j]==0) dp[0][j]=1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(maze[i][j]) continue;
dp[i][j]=dp[i-1][j]+dp[i][j-1];
}
}
return dp[n][m];
}
int main(){
cin>>n>>m>>X>>Y;
maze.resize(n+1,vector<int>(m+1,0));
dp.resize(n+1,vector<long long int>(m+1,0));
maze[X][Y]=1;
for(int i=0;i<8;i++){
int nx=X+way1[i][0];
int ny=Y+way1[i][1];
if(isvalid(nx,ny)){
maze[nx][ny]=1;
}
}
long long int ret=find();
cout<<ret;
return 0;
}
by niuniudundun @ 2024-11-28 21:14:25
@helloworldhahaha你在写什么?
by pjh0625 @ 2024-11-30 10:12:36
@helloworldhahaha 虽然不知道你在写些什么 但这题答案在这:
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
char ss[20],ans[100],k;
int main() {
scanf("%d",&n);
for(int i=1; i<=n; i++) {
scanf("%s",&ss);
if(isalpha(ss[0])) {
k=ss[0];
scanf("%d%d",&x,&y);
} else {
x=atoi(ss);
scanf("%d",&y);
}
if(k=='a')
sprintf(ans,"%d+%d=%d",x,y,x+y);
else if(k=='b')
sprintf(ans,"%d-%d=%d",x,y,x-y);
else
sprintf(ans,"%d*%d=%d",x,y,x*y);
printf("%s\n%d\n",ans,strlen(ans));
}
return 0;
}
by helloworldhahaha @ 2024-11-30 20:48:12
发错地方了,不是这个题