pvz漫画吧 关注:234贴子:5,413
  • 5回复贴,共1
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int map[100][100];
int temp[100][100];
int x[4]={0,0,1,-1};
int y[4]={-1,1,0,0};
int ans;
int search(int a,int b,int m,int n)
{
for(int i=0;i<=a;i++)
for(int k=0;k<=b;k++)
{
map[i][k]=1;
}
if(m==a&&n==b)
ans++;
if(m<=a&&n<=b)
{
for(int p=0;p<=3;p++)
{
if(temp[m+x[p]][n+y[p]]==0&&map[m+x[p]][n+y[p]]==1)
temp[m][n]=1;
search(a,b,m,n);
temp[m][n]=0;
}
}
}
int main()
{
int o,p;
cin>>o>>p;
//for(int i=1;i<=o;i++)
//for(int k=1;k<=p;k++)
//{
//map[i][k]=1;
//}
search(4,4,o,p);
cout<<ans;
return 0;
}


IP属地:中国香港1楼2019-03-20 17:17回复
    #include<iostream>
    #include<cstdlib>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int tot;
    int ini[5000][10];
    int search(int x,int w,int k)//x为调料序号,w为美味程度,k为累加值
    {
    if(x>11)
    return 0;
    else
    if(k<w)
    for(int i=1;i<=3;i++)
    {search(x+1,w,k+i);
    ini[tot][x]=t;
    }
    if(k==w&&x==11)
    tot=tot+1;
    return 0;
    if(w>30)
    tot=0;
    }
    int main()
    {
    int m;
    cin>>m;
    search(1,m,0);
    cout<<tot<<endl;
    for(int k=1;k<=tot;k++)
    for(int u=1;u<=10;u++)
    {
    cout<<ini[k][u]<<" ";
    if(u==10)
    cout<<endl;
    }
    return 0;
    }


    IP属地:中国香港4楼2019-04-03 16:16
    回复
      P1706
      #include<iostream>
      #include<cstdlib>
      #include<cstdio>
      #include<cstring>
      #include<algorithm>
      using namespace std;
      int main()
      {
      int a[15];
      int n;
      cin>>n;
      for(int i=1;i<=n;i++)
      {a[i]=i;
      }
      do{
      for(int k=1;k<=n;k++)
      printf("%5d",a[k]);
      printf("%d","\n");
      }
      while(next_permutation(a,a+n+1));
      return 0;
      }


      IP属地:中国香港5楼2019-04-03 17:25
      回复
        #include<iostream>
        #include<cstdio>
        #include<cstdlib>
        #include<algorithm>
        #include<cstring>
        #include<cmath>
        #define eps 1e-7
        using namespace std;
        int a[100];
        int n;
        int q=0;
        float f(float x)
        {
        for(int j=n;j>=0;j--)
        {
        q+=a[j]*pow(x,j);
        }
        }
        float search(float l,float r)
        {
        while(l+eps<r)
        {
        float lmid=(2*l+r)/3;
        float rmid=(l+2*r)/3;
        if(f(lmid)<f(rmid))
        l=lmid;
        else
        r=rmid;
        }
        return l;
        }
        int main()
        {
        float L;
        float R;
        cin>>n>>L>>R;
        for(int i=n;i>=0;i--)
        {
        cin>>a[i];
        }
        cout<<search(L,R);
        return 0;
        }


        IP属地:中国香港6楼2019-04-10 16:46
        回复
          #include<iostream>
          #include<cstdio>
          #include<cstdlib>
          #include<cstring>
          #include<algorithm>
          using namespace std;
          int A;
          int B;
          int target[100005];
          int choose[100005];
          int check(int x)
          {
          }
          long long erfen(long long l,long long r)
          {
          while(l<r)
          {
          long long mid=(l+r+1)/2;
          if(check(mid))
          l=mid;
          else
          r=mid-1;
          }
          return l;
          }
          int main()
          {
          cin>>A>>B;
          for(int i=1;i<=A;i++)
          {
          cin>>target[i];
          }
          sort(target+1,target+A+1);
          return 0;
          }


          IP属地:中国香港7楼2019-04-17 17:17
          收起回复
            #include<iostream>
            #include<cstdlib>
            #include<cstdio>
            #include<cstring>
            #include<algorithm>
            using namespace std;
            int cp;
            int ct;
            int rp;
            int T;
            int M;
            int now;
            int best;
            int ans;
            int time[114];
            int herb[114];
            double border(int x)
            {
            while(x<=M)
            {
            rp=rp+herb[x];
            x++;
            }
            return rp+cp;
            }
            int dfs(int now)
            {
            if(now==M+1)
            {
            if(cp>best)
            {
            best=cp;
            }
            return best;
            }
            else if(ct<T&&border(now)>best)
            {
            ct=ct+time[now];
            cp=cp+herb[now];
            dfs(now+1);
            ct=ct-time[now];
            cp=cp-time[now];
            }
            //{
            //dfs(now+1);
            //}
            }
            int main()
            {
            cin>>T>>M;
            for(int i=1;i<=M;i++)
            {
            cin>>time[i]>>herb[i];
            }
            cout<<dfs(1);
            return 0;
            }


            IP属地:中国香港8楼2019-05-08 17:16
            回复