分享一些我常用的代码优化技巧,希望对你有帮助。 1. 多表达式多 if 判断 我们可以在数组中存储多个值,并且可以使用数组include方法。 1 // 长 2 if (x 'abc' || x 'def' || x 'ghi' || x 'jkl') { //logic} 3 // 短 4 if ...
分类:
编程语言 时间:
2021-02-05 10:39:53
阅读次数:
0
P3052 [USACO12MAR]Cows in a Skyscraper G 预处理出每种状态的体积和,然后枚举子集转移。 时间复杂度 \(O\left(3^n\right)\)。 code: #include<bits/stdc++.h> using namespace std; #defin ...
分类:
其他好文 时间:
2021-02-05 10:29:05
阅读次数:
0
1、 #include <stdio.h> #define NUMBER 5 int main(void) { int a[NUMBER]; int i; puts("please input several numbers."); for (i = 0; i < NUMBER; i++) { pr ...
分类:
编程语言 时间:
2021-02-04 12:18:06
阅读次数:
0
https://www.bilibili.com/video/BV1g4411H78N?p=5 main.cpp 文件 #include "mywidget.h" #include <QApplication>// 包含一个应用程序类的头文件 //main程序入口 argc命令行变量的数量 argv ...
分类:
其他好文 时间:
2021-02-04 12:09:23
阅读次数:
0
暴力朴素无优化写法: #include<bits/stdc++.h> using namespace std; const int maxn=1e3+5; int dp[maxn][maxn]; int v[maxn],w[maxn]; int main(){ int n,m;scanf("%d%d ...
分类:
其他好文 时间:
2021-02-04 12:02:33
阅读次数:
0
1.拷贝构造函数代码: 当类对象用于值传递时,会调用拷贝构造函数 #include<iostream> using namespace std; class CExample { private: int a; public: //构造函数 CExample(int b) { a=b; printf ...
分类:
编程语言 时间:
2021-02-04 11:44:47
阅读次数:
0
循环 1 #include<iostream> 2 3 using namespace std; 4 int main() 5 { 6 int my_array[] = { 1,2,3,4,5,6,7,8 }; 7 // 不会改变 my_array 数组中元素的值 8 // x 将使用 my_arr ...
分类:
编程语言 时间:
2021-02-04 11:44:06
阅读次数:
0
set的常见用法 #include <set> set<int> st; set<int>::iterator it; //迭代器 st.insert(int); //插入一个值 st.erase(int); // 删除一个值 st.erase(iterator); //删除迭代器指向的值 st.e ...
分类:
其他好文 时间:
2021-02-03 11:06:06
阅读次数:
0
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> typedef struct ListNode{ int val; ListNode* next; }Node_t, *pNode_t; void print_l ...
分类:
编程语言 时间:
2021-02-03 11:00:00
阅读次数:
0
修改一座山可能同时改变其两侧山的类型。贪心地考虑,要么是修改成其左侧山的高度要么是修改成其右侧山的高度,这样能够在使得当前山不成为山峰和山谷的同时让两侧的山尽可能不成为山峰和山谷。 时间复杂度 \(O\left(\sum n\right)\)。 #include<bits/stdc++.h> usi ...
分类:
其他好文 时间:
2021-02-03 10:39:38
阅读次数:
0