Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
393 B
1
Indexable
Never
#define ll long long
class Solution {
public:
    long long flowerGame(int n, int m) {
        ll odd1=0,even1=0,even2=0,odd2=0;
        for(int i=1;i<=n;i++){
            if(i%2==0) even1++;
            else odd1++;
        }
        for(int i=1;i<=m;i++){
            if(i%2==0) even2++;
            else odd2++;
        }
        ll sum=odd1*even2 + even1*odd2;
        return sum;
    }
};
Leave a Comment