挺好想的二分题吧。 const int N=1e5+10; PII a[N]; int n,k; bool check(int mid) { int res=0; for(int i=0;i<n;i++) res+=(a[i].fi/mid)*(a[i].se/mid); return res>=k ...
分类:
其他好文 时间:
2021-01-22 12:03:44
阅读次数:
0
c++从浅拷贝和深拷贝到默认拷贝函数 1. 深度拷贝和浅拷贝 深度拷贝和浅拷贝在c语言中就经常遇到的了,在这里我简单描述。 一般的赋值操作是深度拷贝: //深度拷贝 int a = 5; int b = a; 所谓深度拷贝,即为在堆栈内存中新开辟了一块区域,存储着拷贝过来的数据。以上述代码为例,a和 ...
分类:
编程语言 时间:
2021-01-21 11:01:26
阅读次数:
0
int main() { cout<<__builtin_ffs(4)<<endl; //返回n的最后一位1的是从后向前第几位 //返回3 cout<<__builtin_ctz(8)<<endl; //返回n的后面的0的个数 //返回3 cout<<__builtin_popcount(11)<< ...
分类:
其他好文 时间:
2021-01-20 11:58:15
阅读次数:
0
std::weak_ptr 避免shared_ptr内存泄漏的利器。 smart pointer 三兄弟性格各异。unque_ptr是独来独往,shared_ptr是左拥右抱,而weak_ptr生来就不是为了单打独斗,了解之后你会发现他总是和shared_ptr出双入对。 既然shared_ptr是 ...
分类:
其他好文 时间:
2021-01-20 11:45:59
阅读次数:
0
steprecision(); setprecision是一个计算机函数,功能是控制输出流显示浮点数的有效数字个数 [1] ,如果和fixed合用的话,可以控制小数点后面有几位。 例如: cout<<steprecision(4)<<321.45678<<endl;//输出结果为:321.5 cou ...
分类:
编程语言 时间:
2021-01-16 12:01:53
阅读次数:
0
思路:维护一个K大小的最小堆,堆顶就是最小的元素,新元素都比堆顶小,当堆中元素个数小于K时,直接进入堆,当堆顶小于新元素时,弹出堆顶,新元素加入堆。 #include <iostream> #include <vector> #include <queue> using namespace std; ...
分类:
其他好文 时间:
2021-01-13 11:29:41
阅读次数:
0
#include<iostream> #include<cstring> #include<algorithm> using namespace std; struct node { string x; //装票数 int num; //装号数 int lenx; //装票数的位数 }s[25]; ...
分类:
编程语言 时间:
2021-01-13 11:00:17
阅读次数:
0
#include <iostream> #include <vector> #include <string> using namespace std; struct Node { int data; Node * next; }; Node * reverseList(Node * head) { ...
分类:
其他好文 时间:
2021-01-11 11:11:15
阅读次数:
0
一、操作如下,可以将json对象转为字符串 Json::Value root; root["name"] = "咸鱼"; root["age"] = 100; string str; Json::FastWriter fast; str = fast.write(root); cout << str ...
分类:
Web程序 时间:
2021-01-08 10:32:42
阅读次数:
0
#include<iostream>using namespace std;int main(){ int oneInt =1; int & ref=oneInt; const int &refc=oneInt; ref=2; cout<<"oneInt="<<oneInt<<","<<"ref=" ...
分类:
其他好文 时间:
2021-01-01 12:35:39
阅读次数:
0