zoukankan      html  css  js  c++  java
  • Honeycomb 题解(思维+转化坐标系)

    题目链接

    题目思路

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

    参考博文

    在这里插入图片描述

    这样建立,但是原博文的坐标转化(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
    ",pr);
        }
        return 0;
    }
    
    
    不摆烂了,写题
  • 相关阅读:
    oracle 监听 添加ip
    重装系统windows
    oracle user pwd
    mybatis
    sum行列合计
    IIS8.5 运行WCF
    exp自动备份在bat中不执行
    oem 重建
    yum install oracle-validated
    MSHflexgrid控件删除选中行
  • 原文地址:https://www.cnblogs.com/hunxuewangzi/p/15138276.html
Copyright © 2011-2022 走看看