598. Range Addition II

class Solution {
public:
    int maxCount(int m, int n, vector<vector<int>>& ops) 
    {
        int nminx = 40001;
        int nminy = 40001;

        // 找到最小的长和宽即可
        for(int i = 0; i < ops.size(); i++)
        {
            if(nminy >= ops[i][0])
            {
                nminy = ops[i][0];
            }
            if(nminx >= ops[i][1])
            {
                nminx = ops[i][1];
            }
            if(nminy >= m)
            {
                nminy = m;
            }
            if(nminx >= n)
            {
                nminx = n;
            }
        }
        if(nminx == 40001 && nminy == 40001)
        {
            return m * n;
        }
        else if(nminx == 40001)
        {
            return n * nminy;
        }
        else if(nminy == 40001)
        {
            return nminx * m;    
        }
        else
        {
            return nminx*nminy;   
        }
    }
};
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, I can help you with that. Here's the code in Python using matplotlib and numpy libraries: ```python import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # Define the function def f(x, y): return 2*x**2 + y**2 # Define the range of t t = np.linspace(-3, 3, 100) # Calculate the x and y values x = np.sin(3*t) y = np.cos(3*t) # Calculate the z values z = f(x, y) # Create a meshgrid for the x and y values X, Y = np.meshgrid(x, y) # Create a figure and three subplots for the different types of plots fig = plt.figure(figsize=(12, 6)) ax1 = fig.add_subplot(2, 3, 1, projection='3d') ax1.plot_wireframe(X, Y, z) ax1.set_xlabel('X') ax1.set_ylabel('Y') ax1.set_zlabel('Z') ax1.set_title('3D Mesh Graph') ax2 = fig.add_subplot(2, 3, 2, projection='3d') ax2.plot_surface(X, Y, z, cmap='viridis') ax2.set_xlabel('X') ax2.set_ylabel('Y') ax2.set_zlabel('Z') ax2.set_title('3D Surface Graph') ax3 = fig.add_subplot(2, 3, 3, projection='3d') ax3.plot_surface(X, Y, z, cmap='viridis') ax3.contour(X, Y, z, zdir='z', offset=-1, cmap='viridis') ax3.set_xlabel('X') ax3.set_ylabel('Y') ax3.set_zlabel('Z') ax3.set_title('3D Surface Graph with Contour Lines') # Create a 2D sectional view graph for x=1 x1 = 1 y1 = np.linspace(-1.2, 1.2, 100) z1 = f(x1, y1) ax4 = fig.add_subplot(2, 3, 4) ax4.plot(y1, z1) ax4.set_xlabel('Y') ax4.set_ylabel('Z') ax4.set_title('2D Sectional View Graph for x=1') plt.show() ``` This code will generate a figure with six subplots. The first three subplots are the 3D mesh graph, 3D surface graph, and 3D surface graph with contour lines, respectively. The fourth subplot is the 2D sectional view graph for x=1. The ranges of the x and y axes are both [-1.2, 1.2], and the range of t is set to [-3, 3].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值