#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e3 + 5;
int T, n, a[N], t[N], b[N], s[N];
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f*=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
signed main(){
T = read();
while(T--){
bool ans = false;
n = read();
memset(a, 0, sizeof(a));
for(int i = 1; i <= n; i++) t[i] = read();
for(int i = 1; i <= n; i++) b[i] = read();
for(int i = 1; i <= n; i++) s[i] = t[i] + t[n - i + 1];
while(true){
bool ok = 1;
for(int i = 1; i <= n; i++)
if(a[i] > b[i]){
ok = 0;
break;
}
if(ok == 0) break;
if((b[1] - a[1]) % s[1] == 0){
bool flag = 1;
int step = (b[1] - a[1]) / s[1];
for(int i = 2; i <= n; i++)
if(b[i] != a[i] + step * s[i]){
flag = 0;
break;
}
if(flag){
ans = true;
break;
}
}
for(int i = 1; i <= n; i++) a[i] += t[i];
}
if(ans) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
第26行为什么不能写 ai>=bi ?