Translate

Views

Friday, August 4, 2023

Solution UVA: 11231 - Black and white painting

 

 Problem  VerdictLangTimeBestRankSubmit Time
 | discuss11231 - Black and white painting AcceptedC++110.0000.000257653 secs ago

Suggest:
- Number of the white right bottom of chessboard is the result
"Any embedded chessboard can be identified uniquely with its lower right corner. 
If we count the number of valid lower-right-hand-corners, we thus have our solution."
(algorithmist.com)



#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
        ios::sync_with_stdio(0); cin.tie(0);
        int n, m, c;
        while(cin >> n >> m >> c && !(n==0 && m==0 && c==0)){
                n-=7, m-=7;
                cout<<(c ? (n*m+1)/2 : n*m/2)<<"\n";
        }
}

No comments: