fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int move(int i, vector<int> &a, vector<int> &b) {
  5. if (i == a.size()) {
  6. return 0;
  7. }
  8.  
  9. return (a[i] * b[i]) + move(i + 1, a, b);
  10. }
  11.  
  12. int main() {
  13. int n;
  14. cin >> n;
  15. vector<int> a(n), b(n);
  16. for (int i = 0; i < n; ++i) {
  17. cin >> a[i];
  18. }
  19. for (int i = 0; i < n; ++i) {
  20. cin >> b[i];
  21. }
  22.  
  23. if (move(0, a, b) == 0) {
  24. cout << "Yes";
  25. } else {
  26. cout << "No";
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Yes