Advertisement
Josif_tepe

Untitled

Feb 15th, 2022
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main(int argc, const char * argv[]) {
  4.     ios_base::sync_with_stdio(false);
  5.     int n, m;
  6.     cin >> n >> m;
  7.     int x;
  8.     int red, yellow, green;
  9.     red = 0;
  10.     yellow = 0;
  11.     green = 0;
  12.      
  13.     for(int i=0;i < n; i++){
  14.         x = m;
  15.         if(i % 3 == 0){
  16.             red += (x+2)/3;
  17.             x--;
  18.             yellow += (x+2)/3;
  19.             x--;
  20.             green += (x + 2) / 3;
  21.              
  22.         }
  23.         else if(i % 3 == 1){
  24.             yellow += (x+2)/3;
  25.             x--;
  26.             green += (x + 2) / 3;
  27.             x--;
  28.             red += (x + 2) / 3;
  29.         }
  30.         else{
  31.             green += (x + 2)/ 3;
  32.             x--;
  33.             red += (x + 2)/3;
  34.             x--;
  35.             yellow += (x + 2)/ 3;
  36.         }
  37.      
  38.     }
  39.     cout << red << " " << yellow << " " << green;
  40.     return 0;
  41.      
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement