删去第7行与第13行的unsigned,程序行为不变。#include <algorithm> #include <iostream> #include <limits> using namespace std; const int MAXN = 105; const int MAXK = 105; int h[MAXN][MAXK]; int f(int n, int m) { if (m == 1) return n; if (n == 0) return 0; int ret = numeric_limits<int>::max(); for (int i = 1; i <= n; i++) ret = min(ret, max(f(n - i, m), f(i - 1, m - 1)) + 1); return ret; } int g(int n, int m) { for (int i = 1; i <= n; i++) h[i][1] = i; for (int j = 1; j <= m; j++) h[0][j] = 0; for (int i = 1; i <= n; i++) { for (int j = 2; j <= m; j++) { h[i][j] = numeric_limits<int>::max(); for (int k = 1; k <= i; k++) h[i][j] = min( h[i][j], max(h[i - k][j], h[k - 1][j - 1]) + 1); } } return h[n][m]; } int main() { int n, m; cin >> n >> m; cout << f(n, m) << endl << g(n, m) << endl; return 0; }
时间: 2024-04-27 08:25:29 浏览: 26
程序的行为不会受到影响,因为在这段代码中,unsigned 和 int 都是可以代表整数的类型,而且这里使用的最大值和最小值都是 numeric_limits<int>::max() 和 numeric_limits<int>::min(),它们返回的都是 int 类型的最大值和最小值,因此没有必要使用 unsigned 类型。
相关问题
#include <STC8H.h>#include <intrins.h> #include <math.h>#include <stdio.h>typedef unsigned char ucha
这段代码是一个C语言程序的头文件引用部分。具体解释如下:
1. `#include <STC8H.h>`:这是引用了一个名为STC8H的头文件,该头文件可能包含了一些与STC8H芯片相关的定义和函数声明。
2. `#include <intrins.h>`:这是引用了一个名为intrins.h的头文件,该头文件可能包含了一些与嵌入式系统中的特殊指令和操作相关的定义和函数声明。
3. `#include <math.h>`:这是引用了一个名为math.h的头文件,该头文件包含了一些与数学运算相关的函数声明和宏定义,例如数学函数sin、cos等。
4. `#include <stdio.h>`:这是引用了一个名为stdio.h的头文件,该头文件包含了一些与输入输出操作相关的函数声明和宏定义,例如printf、scanf等。
5. `typedef unsigned char ucha`:这是一个类型定义语句,将unsigned char类型重命名为ucha,方便在代码中使用ucha作为变量类型。
#include<REGX51.H> #include<intrins.h> #define uchar unsigned char #define uint unsigned int什么意思
这段代码是一个基于51单片机的C语言程序,其中:
- `#include<REGX51.H>` 是包含了51单片机的头文件,可以使用其中定义的寄存器及功能;
- `#include<intrins.h>` 是包含了汇编语言的头文件,可以使用其中定义的内嵌汇编函数;
- `#define uchar unsigned char` 定义了一个名为`uchar`的宏,表示无符号字符类型;
- `#define uint unsigned int` 定义了一个名为`uint`的宏,表示无符号整数类型。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-dosexec](https://img-home.csdnimg.cn/images/20210720083343.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)