Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main () {
- int n;
- std::cin >> n;
- int a[n];
- for (int i = 0;i<n;i++) {
- int p ;
- std::cin >> p;
- a[i] = p;
- }
- int temp = 0;
- for (int i = n-2;i>=0;i--) {
- if (a[i] != a[n-1]) temp++;
- }
- int pepa = 0;
- if (temp%2 ==0) {
- for (int i = 0;i<n-1;i++) {
- if (a[i]!=a[n-1]) pepa += a[i];
- }
- std::cout << pepa;
- return 0;
- }
- else {
- pepa = 1;
- for (int i = 0;i<n;i++) {
- if (a[i] != a[n-1]) pepa *=a[i];
- }
- std::cout << pepa;
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement