Advertisement
Josif_tepe

Untitled

Mar 7th, 2024
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <map>
  5. #include <algorithm>
  6. using namespace std;
  7. typedef long long ll;
  8.    
  9. int main()
  10. {
  11.     int n, m, x, y;
  12.     cin >> n >> m >> x >> y;
  13.    
  14.     int p1 = 0, p2 = 0;
  15.     for(int i = 0; i <= x; i++) {
  16.         for(int j = 0; j <= x; j++) {
  17.             if(i + j <= y) {
  18.                 p1 = i;
  19.                 p2 = j;
  20.             }
  21.         }
  22.     }
  23.     int sum1 = 0;
  24.     for(int i = 0; i < n; i++) {
  25.         for(int j = 0; j < m; j++) {
  26.             if(i % 2 == 0 and j % 2 == 0) {
  27.                 sum1 += p1;
  28.             }
  29.             else if(i % 2 == 0 and j % 2 == 1) {
  30.                 sum1 += p2;
  31.             }
  32.             else if(i % 2 == 1 and j % 2 == 0) {
  33.                 sum1 += p2;
  34.             }
  35.             else {
  36.                 sum1 += p1;
  37.             }
  38.         }
  39.     }
  40.     int sum2 = 0;
  41.     for(int i = 0; i < n; i++) {
  42.         for(int j = 0; j < m; j++) {
  43.             if(i % 2 == 0 and j % 2 == 0) {
  44.                 sum2 += p2;
  45.             }
  46.             else if(i % 2 == 0 and j % 2 == 1) {
  47.                 sum2 += p1;
  48.             }
  49.             else if(i % 2 == 1 and j % 2 == 0) {
  50.                 sum2 += p1;
  51.             }
  52.             else {
  53.                 sum2 += p2;
  54.             }
  55.         }
  56.     }
  57.     cout << max(sum1, sum2) << endl;
  58.     return 0;
  59. }
  60. // 2222222222
  61. // 22222222222
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement