29 条题解

  • 0
    @ 2025-12-22 16:10:39
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        cout<<0<<' '<<20<<endl;
        for(int i=1;i<=19;i++)
            if((100-i*6)%5==0) cout<<i<<' '<<(100-i*6)/5<<endl;
        return 0;
    }
    
    • 0
      @ 2025-12-18 16:03:50
      y+=n%10;
                  n=n/10;
      
      • 0
        @ 2025-12-18 15:12:33
        #include <bits/stdc++.h>
        using namespace std;
        int n,k;
        char f[1000];
        void sy(int x,int y, int t)
        {
            if(y==n+1)
            {
                if(t+x==0)
                {
                    cout<<"1";
                    for(int i=2;i<=n;i++)
                       cout<<f[i]<<i;
                       cout<<endl;
                }
                return ;
            }
            f[y]=' ';
            if(x>0) sy(x*10+y,y+1,t);
               else sy(x*10-y,y+1,t);
            f[y]='+';
            sy(y,y+1,t+x);
            f[y]='-';
            sy(-y,y+1,t+x);
        }
        int main()
        {
            cin>>n;
            sy(1,2,0);
            return 0;
        }
        
        • 0
          @ 2025-12-16 16:13:28
          #include <bits/stdc++.h>
          using namespace std;
          int fx[5]={0,-1,1,0,0},fy[5]={0,0,0,-1,1},n,m,ans=INT_MAX,f[100][100],x,y;
          bool p;
          char a[100][100];
          void sy(int x,int y,int t)
          {
              if(a[x][y]=='a')
              {
                  p=1;
                  if(t<ans) ans=t;
                  return ;
              }
              for(int i=1;i<=4;i++)
              {
                  int tx=x+fx[i];
                  int ty=y+fy[i];
                  if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&a[tx][ty]!='#')
                  {
                      if(a[tx][ty]=='x'&&t+2<=f[tx][ty])
          			{
                      	f[tx][ty]=t+2;
                      	sy(tx,ty,t+2);
          			} 
                      else if(t+1<f[tx][ty])
          			{
                      	f[tx][ty]=t+1;
                      	sy(tx,ty,t+1);
          			}
                  }
              }
          }
          int main()
          {
              cin>>n>>m;
              for(int i=1;i<=n;i++)
                  for(int j=1;j<=m;j++) cin>>a[i][j];
              for(int i=1;i<=n;i++)
                  for(int j=1;j<=m;j++)
          		{
                  	if(a[i][j]=='r') x=i,y=j;
                  	f[i][j]=INT_MAX;
          		}
              sy(x,y,0);
              if(p==1) cout<<ans;
              else cout<<"Impossible";
              return 0;
          }
          
          • 0
            @ 2025-12-9 17:02:55
            
            

            #include <bits/stdc++.h> using namespace std; int fx[5]={0,-1,1,0,0},fy[5]={0,0,0,-1,1},n,m,tx,ty,s,ans,maxx,minx,maxy,miny; bool f[1100][1100]; char a[1100][1100]; void sy(int x,int y) { for(int i=1;i<=4;i++) { tx=x+fx[i]; ty=y+fy[i]; if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&f[tx][ty]0&&a[tx][ty]'#') { s++; f[tx][ty]=1; maxx=max(maxx,tx); minx=min(minx,tx); maxy=max(maxy,ty); miny=min(miny,ty); sy(tx,ty); } } } int main() { cin>>n>>m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i][j]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(a[i][j]=='#'&&f[i][j]==0) { s=1; f[i][j]=1; minx=maxx=i; miny=maxy=j; sy(i,j); if((maxx-minx+1)*(maxy-miny+1)==s) ans++; else { cout<<"Bad placement."; return 0; } } cout<<"There are "<<ans<<" ships."; return 0; }

            
            
            • 0
              @ 2025-12-9 15:33:39
              using namespace std;
              int fx[5]={0,-1,1,0,0},fy[5]={0,0,0,-1,1},n,m,tx,ty,s,maxn=INT_MIN;
              bool f[1100][1100];
              char a[1100][1100];
              void sy(int x,int y)
              {
              	for(int i=1;i<=4;i++)
                  {
              		tx=x+fx[i];
              		ty=y+fy[i];
              		if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&f[tx][ty]==0&&a[tx][ty]=='*')
                      {
              			s++;
              			f[tx][ty]=1;
              			sy(tx,ty);
              		}
              	}
              }
              int main()
              {
              	cin>>m>>n;
              	for(int i=1;i<=n;i++)
              		for(int j=1;j<=m;j++) cin>>a[i][j];
              	for(int i=1;i<=n;i++)
              		for(int j=1;j<=m;j++)
              			if(a[i][j]=='*'&&f[i][j]==0)
                          {
              				f[i][j]=1;
              				s=1;
              				sy(i,j);
              				maxn=max(maxn,s);
              			}
              	cout<<maxn;
              	return 0;
              }
              
              • 0
                @ 2025-11-17 17:44:02

                谁能告诉我,为什么我提交了3次,显示我没交!

                • 0
                  @ 2025-11-14 16:39:35
                  using namespace std;
                  long long n,a[1000][1000],f[1000][1000];
                  int sy(int x,int y)
                  {
                      if(x==n) f[x][y]=a[x][y];
                  	if(x==n+1) return 0;
                  	if(f[x][y]==0) f[x][y]=max(sy(x+1,y),sy(x+1,y+1))+a[x][y];
                      return f[x][y];
                  }
                  int main()
                  {
                      cin>>n;
                  	for(int i=1;i<=n;i++)
                  	    for(int j=1;j<=i;j++) cin>>a[i][j];
                  	cout<<sy(1,1);
                  	return 0;
                  }
                  
                  • 0
                    @ 2025-11-14 15:26:12
                    using namespace std;
                    int v[200],w[200],n,V;
                    int sy(int s,int k)
                    {
                        if(s<=0||k==0) return 0;
                        if(s>=v[k])return max(sy(s,k-1),sy(s-v[k],k-1)+w[k]);
                        else return sy(s,k-1);
                    }
                    int main()
                    {
                    	cin>>n>>V;
                    	for(int i=1;i<=n;i++) cin>>v[i]>>w[i];
                        cout<<sy(V,n);
                    }
                    

                    信息

                    ID
                    103
                    时间
                    1000ms
                    内存
                    256MiB
                    难度
                    7
                    标签
                    递交数
                    57
                    已通过
                    15
                    上传者