头像




离线:2小时前


最近来访(0)

活动打卡代码 AcWing 790. 数的三次方根


3天前
//这里填你的代码^^
#include<iostream>
using namespace std;
int main()
{
    double x;
    cin>>x;
   double l=-100,r=100;
    while(r-l>1e-8)
    {
        double mid= (r+l)/2;
        if(mid*mid*mid>=x) r=mid;
        else l=mid;
    }
    printf("%.6lf",l);
    return 0;
}
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~


活动打卡代码 AcWing 789. 数的范围


3天前
//这里填你的代码^^
#include<iostream>
using namespace std;
const int N= 1e6+10;
int q[N];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d",&q[i]);
    while(m--)
    {
        int x;
        scanf("%d",&x);
        int l=0,r=n-1;

        while(l<r)
        {
            int  mid=l+r>>1;
            if(q[mid]>=x) r=mid;
            else l=mid+1;
        }
        if(q[l]!=x) cout<<"-1 -1"<<endl;
        else
        {
            cout<<l<<" ";
            int l=0,r=n-1;
            while(l<r)
            {
                int mid =l+r+1>>1;
                if(q[mid]<=x) l=mid;
                else r=mid-1;

            }
            cout<<l<<endl;
        }
    }
    return 0;
}
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~




3天前

include[HTML_REMOVED]

using namespace std;
const int N= 1e6+10;
int q[N];
int main()
{
int n,m;
scanf(“%d%d”,&n,&m);
for(int i=0;i<n;i++) scanf(“%d”,&q[i]);
while(m–)
{
int x;
scanf(“%d”,&x);
int l=0,r=n-1;

    while(l<r)
    {
        int  mid=l+r>>1;
        if(q[mid]>=x) r=mid;
        else l=mid+1;
    }
    if(q[l]!=x) cout<<"-1 -1"<<endl;
    else
    {
        cout<<l<<" ";
        int l=0,r=n-1;
        while(l<r)
        {
            int mid =l+r+1>>1;
            if(q[mid]<=x) l=mid;
            else r=mid-1;

        }
        cout<<l<<endl;
    }
}
return 0;

}





1个月前

include[HTML_REMOVED]

include[HTML_REMOVED]

include[HTML_REMOVED]

include[HTML_REMOVED]

using namespace std;
const int N=100;
int g[N][N];
int d[N][N];
int n,m;
typedef pair[HTML_REMOVED]PII;
queue[HTML_REMOVED]q;
int bfs()
{
memset(d,-1,sizeof d);
d[0][0]=0;
q.push({0,0});
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
while(!q.empty())
{
auto t=q.front();
q.pop();
for(int i=0;i<4;i++)
{
int x=t.first+dx[i],y=t.second+dy[i];
if(x>=0&&x[HTML_REMOVED]=0&&y[HTML_REMOVED]>n>>m;
for(int i=0;i[HTML_REMOVED]>g[i][j];

}
cout<<bfs();

}