题解 | #LP钱不够#
LP钱不够
https://ac.nowcoder.com/acm/problem/14582
我以前在写啥呀
#include<iostream>
#include<stack>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
int a[22][22],t,n,sum = 0,ans =1e+7;
void F(int i,int j,int sum){
sum+=a[i][j];
if(i == n&&j ==n){
ans = min(ans,sum);
return;
}
if(i<n) F(i+1,j,sum);
if(j<n) F(i,j+1,sum);
}
int main(){
cin>>t;
while(t--){
cin>>n;
ans =1e9+7;
memset(a,0,sizeof(a));
for(int j = 1;j<=n;j++){
for(int k =1;k<=n;k++)
cin>>a[j][k];
}
F(1,1,0);
cout<<ans<<endl;
}
return 0;
}