Submission #2126232


Source Code Expand

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	ll h,hd,w,wd,i,a,b,c;
	cin >> h >> w;
	if(!(h%3) && !(w%3)){
		cout << 0 << endl;
		return 0;
	}
	ans = min(h,w);
	for(i=1ll; i<h; ++i){
		a = w * i;
		hd = h - i;
		b = hd * (w/2);
		c = hd * (w - (w/2));
		ans = min(ans,max(a,c)-min(a,b));
	}
	for(i=1ll; i<w; ++i){
		a = h * i;
		wd = w - i;
		b = wd * (h/2);
		c = wd * (h - (h/2));
		ans = min(ans,max(a,c)-min(a,b));
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Chocolate Bar
User ransewhale
Language C++14 (GCC 5.4.1)
Score 0
Code Size 799 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:2: error: ‘ans’ was not declared in this scope
  ans = min(h,w);
  ^