Codeforces Round #511 (Div. 1) T2 Little C Loves 3 II

题目

Little C loves number «3» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n×mn \times mn×m. The cell in the xxx-th row and in the yyy-th column is called (x,y)(x,y)(x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between which is exactly 333. The Manhattan distance between two cells (xi,yi)(x_i,y_i)(xi,yi) and (xj,yj)(x_j,y_j)(xj,yj) is defined as ∣xi−xj∣+∣yi−yj∣|x_i-x_j|+|y_i-y_j|xixj+yiyj.
He want to place as many chessmen as possible on the chessboard. Please help him find the maximum number of chessmen he can place.
Input
A single line contains two integers nnn and mmm (1≤n,m≤1091 \leq n,m \leq 10^91n,m109) — the number of rows and the number of columns of the chessboard.
Output
Print one integer — the maximum number of chessmen Little C can place.
Examples
inputCopy
2 2
outputCopy
0
inputCopy
3 3
outputCopy
8
Note
In the first example, the Manhattan distance between any two cells is smaller than 333, so the answer is 000.
In the second example, a possible solution is (1,1)(3,2)(1,1)(3,2)(1,1)(3,2), (1,2)(3,3)(1,2)(3,3)(1,2)(3,3),(2,1)(1,3)(2,1)(1,3)(2,1)(1,3), (3,1)(2,3)(3,1)(2,3)(3,1)(2,3).

和史前巨佬ldx还有dzy神仙一起做的

这道题…

可以说是打表吧

首先我们可以观察到,对于任意一个1∗61*616或者2∗42*424的格子,都是可以填满的,

那也就说如果有一边长能被6或者4给整除,那就是可以填满的

然后对于5*5以下的了,我们可以直接打表预处理出来(因为有一些特殊情况吧)

然后。。

就被2*7给hack了

然后特判了一个2*7就过了

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int tr[5][5]={ {0,0,0,2,4},
			   {0,0,4,8,10},
			   {0,4,8,12,14},
			   {2,8,12,16,18},
			   {4,10,14,18,24}};
int main() {
	int n,m;
	cin>>n>>m;
	if(n<m) swap(n,m);
	ll ans=0;
	if(m==1)ans+=n/6*6,n%=6,ans+=tr[0][n-1];
	else if(n%4==0 || m%4==0)ans=(ll)n*m;
	else if(n%6==0 || m%6==0)ans=(ll)n*m;
	else if(n<=5 && m<=5)ans=tr[n-1][m-1];
	else if(n==7 && m==2)ans=12;else ans=(ll)n*m/2*2;
	cout<<ans<<'\n';
} 

反正dzy神仙带我飞,什么都不怕

转载于:https://www.cnblogs.com/forever-/p/9736068.html

根据提供的引用内容,Codeforces Round 511 (Div. 1)是一个比赛的名称。然而,引用内容中没有提供与这个比赛相关的具体信息或问题。因此,我无法回答关于Codeforces Round 511 (Div. 1)的问题。如果您有关于这个比赛的具体问题,请提供更多的信息,我将尽力回答。 #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Codeforces Round 867 (Div. 3)(A题到E题)](https://blog.csdn.net/wdgkd/article/details/130370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值