题目链接

题目思路

要考虑转化坐标系,这种题目太阴间了

参考博文

Honeycomb 题解(思维+转化坐标系)_#include

这样建立,但是原博文的坐标转化\(dx,dy\)稍微有点小问题

其他的写的很好

代码

#include<bits/stdc++.h>
#define fi first
#define se second
#define debug cout<<"I AM HERE"<<endl;
using namespace std;
typedef long long ll;
const int maxn=2e5+5,inf=0x3f3f3f3f,mod=998244353;
const double eps=1e-6;
ll x;
ll a[3],b[3];
int dx[]={0,1,0,-1,-1,0,1};
int dy[]={0,0,1,1,0,-1,-1};
signed main(){
    int _;scanf("%d",&_);
    while(_--){
        for(int i=1;i<=2;i++){
            scanf("%lld",&x);
            ll l=1,r=1e9,ans=-1;
            while(l<=r){
                ll mid=(l+r)/2;
                if(1+3*mid*(mid-1)>=x){
                    ans=mid;
                    r=mid-1;
                }else{
                    l=mid+1;
                }
            }
            a[i]=0;
            b[i]=-ans+1;
            ll num=1+3*ans*(ans-1)-x;
            for(int j=1;j<=6;j++){
                ll cg=min(num,ans-1);
                num-=cg;
                a[i]+=dx[j]*cg;
                b[i]+=dy[j]*cg;
            }
        }
        ll chax=a[1]-a[2];
        ll chay=b[1]-b[2];
        ll pr=0;
        if(chax*chay<0) pr=max(abs(chax),abs(chay))+1;
        else pr=abs(chax)+abs(chay)+1;
        printf("%lld\n",pr);
    }
    return 0;
}

卷也卷不过,躺又躺不平