提出 #1296305
ソースコード 拡げる
/*{{{*/
// think twice code once
// Start:[]
// End :[]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "
#define x first
#define y second
#define mp make_pair
#ifdef __linux__
#define getchar getchar_unlocked
#define LLFORMAT "%lld"
#else
#define LLFORMAT "%I64d"
#endif
typedef long long LL;
template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }
template <class T> void read(T& a) {
char c = getchar(); T f = 1; a = 0;
for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
a *= f;
}
/*}}}*/
int N, M;
LL ans;
void work(int N, int M)
{
rep(i, 1, N)
{
LL a = (LL) M * i;
LL b = (LL) (M / 2) * (N - i);
LL c = (LL) ((M + 1) / 2) * (N - i);
if(b == 0 || c == 0) continue;
//disp(a), disp(b), disp(c), puts("");
//disp(min(min(abs(a - b), abs(b - c)), abs(a - c))), puts("");
chkmin(ans, max(max(abs(a - b), abs(b - c)), abs(a - c)));
b = (LL) ((N - i) / 2) * M;
c = (LL) ((N - i + 1) / 2) * M;
chkmin(ans, max(max(abs(a - b), abs(b - c)), abs(a - c)));
}
}
int main()
{
#ifdef Leeson
freopen("tmp.in", "r", stdin);
freopen("tmp.out", "w", stdout);
#endif
ans = LLONG_MAX;
read(N), read(M);
work(N, M);
work(M, N);
cout << ans << endl;
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
C - Chocolate Bar |
| ユーザ |
leeson |
| 言語 |
C++14 (GCC 5.4.1) |
| 得点 |
400 |
| コード長 |
1642 Byte |
| 結果 |
AC |
| 実行時間 |
5 ms |
| メモリ |
384 KiB |
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
400 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
| All |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 0_00.txt |
AC |
1 ms |
256 KiB |
| 0_01.txt |
AC |
1 ms |
256 KiB |
| 0_02.txt |
AC |
1 ms |
256 KiB |
| 0_03.txt |
AC |
2 ms |
256 KiB |
| 0_04.txt |
AC |
3 ms |
256 KiB |
| 1_00.txt |
AC |
1 ms |
256 KiB |
| 1_01.txt |
AC |
2 ms |
256 KiB |
| 1_02.txt |
AC |
2 ms |
256 KiB |
| 1_03.txt |
AC |
2 ms |
256 KiB |
| 1_04.txt |
AC |
2 ms |
256 KiB |
| 1_05.txt |
AC |
2 ms |
256 KiB |
| 1_06.txt |
AC |
2 ms |
256 KiB |
| 1_07.txt |
AC |
2 ms |
256 KiB |
| 1_08.txt |
AC |
2 ms |
256 KiB |
| 1_09.txt |
AC |
2 ms |
256 KiB |
| 1_10.txt |
AC |
5 ms |
384 KiB |
| 1_11.txt |
AC |
2 ms |
256 KiB |
| 1_12.txt |
AC |
2 ms |
256 KiB |
| 1_13.txt |
AC |
2 ms |
256 KiB |
| 1_14.txt |
AC |
2 ms |
256 KiB |