fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define IO ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0)
  4. typedef long long ll;
  5. const int N = 1e5 + 4 , MOD = 1e9 + 7 ;
  6. int n , a[N] , b[N] , ans ;
  7. bool solve(int idx)
  8. {
  9. if(idx == n + 1)
  10. return ans == 0 ;
  11. ans += a[idx] * b[idx] ;
  12. solve(idx + 1) ;
  13. return ans == 0 ;
  14. }
  15. int main() {
  16. IO ;
  17. cin>>n ;
  18. for(int i=1 ; i <= n ; i++)
  19. cin>>a[i] ;
  20. for(int i=1 ; i <= n ; i++)
  21. cin>>b[i] ;
  22. if(solve(1))
  23. cout<<"Yes\n" ;
  24. else
  25. cout<<"No\n" ;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
Yes