网站首页 站内搜索

搜索结果

查询Tags标签: std,共有 1098条记录
  • luogu P2261 [CQOI2007]余数求和 (数论分块)

    这题要推一下式子,注意涉及到取模的式子都要尽量展成减去下取整的形式。 注意,这里求和符号是求到n,因此分块里面 l 的范围就是l<=n,然后对于n大于k的情况需要特判一下。1 #include "bits/stdc++.h"2 using namespace std;3 typedef long long LL;4 LL…

    2022/7/28 6:53:58 人评论 次浏览
  • 蔚来杯2022牛客暑期多校训练营1

    比赛链接 A 题解 知识点:贪心。 将区间按左端点排序,合并区间,记录所有区间之间断开的长度即可。 时间复杂度 O(nlogn)O(nlog⁡n) 空间复杂度 O(n)O(n) 代码 #include <bits/stdc++.h> #define ll long long using namespace std; struct node { ll l, r; }a[…

    2022/7/28 6:53:51 人评论 次浏览
  • C++初始化列表

    语法:构造函数():属性1(值1),属性2(值2),…{}#include<iostream> using namespace std;class WLM { public:WLM(int a,int b,int c):m_a(a),m_b(b),m_c(c){}int m_a;int m_b;int m_c; };void test() {WLM zjy(10,20,30);cout << "m_a =" << …

    2022/7/28 1:22:48 人评论 次浏览
  • C++ 中的Lambda表达式

    目录简介捕获原理Lambda回调参考 简介Lambda 表达式(lambda expression)是一个匿名函数,Lambda表达式基于数学中的λ演算得名,直接对应于其中的lambda抽象(lambda abstraction),是一个匿名函数,即没有函数名的函数。Lambda表达式可以表示闭包(注意和数学传统意义…

    2022/7/27 14:23:02 人评论 次浏览
  • c++类型萃取

    判断两个类型的关系#include <iostream> #include <type_traits>using std::cout; using std::endl;// is_same is used to judge two data types same or not during compiling void test_is_same() {cout << "test is_same:" << endl…

    2022/7/26 14:25:03 人评论 次浏览
  • C++ 快速读取大文件

    方法一、clock_t start = clock(); ifstream fin(objpath,std::ios::binary);vector<char> buf(fin.seekg(0,std::ios::end).tellg()); fin.seekg(0,std::ios::beg).read(&buf[0],static_cast<std::streamsize>(buf.size()));fin.close(); clock_t end = …

    2022/7/26 14:25:01 人评论 次浏览
  • C++ 中 shared_ptr weak_ptr

    shared_ptrstd::shared_ptr<int> sp1 = new int(); // shared count = 1, weak count = 0 std::shared_ptr<int> sp2(sp1); // shared count = 2, weak count = 0 std::shared_ptr<int> sp3 = sp2; // shared count = 3, weak count = …

    2022/7/24 1:25:08 人评论 次浏览
  • PAT乙级 1002 写出这个数 C++

    //读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。 #include <iostream>#include <stdio.h>#include <string.h> int main(void){ char num[102] = { 0 }; char pinyin[3] = { 0 }; int i = 0; int sum = 0; int…

    2022/7/16 1:22:57 人评论 次浏览
  • terminate called after throwing an instance of ‘std::logic_error‘错误修改方法

    错误提示:准确说编译器并没有报错,但在终端有如下提示: terminate called after throwing an instance of std::logic_error what(): basic_string::_S_construct null not valid12修改方法:检查一下程序中是否给一个string类型的变量初始化为0的情况。搜索 复制

    2022/7/15 23:23:37 人评论 次浏览
  • C++(17):filesystem

    C++17将文件系统的操作封装了进来,从而可以跨平台的操作文件系统: #include <iostream> #include <fstream> #include <cstdlib> #include <filesystem> using namespace std::filesystem;int main() {create_directories("./sandbox/a/b&…

    2022/7/14 1:20:57 人评论 次浏览
  • 我的马蜂

    真的是,到最后还是从快读的行列里退出来了。 说明一下我博客里面奇奇怪怪的八格缩进是一个 bug ,我还在找 bug 的路上( 实际上我是一个标准的四格党,当然我也不会觉得所有其他缩进的就不好看( 标准板子: /**/ #include <bits/stdc++.h> using namespace std;#…

    2022/7/13 23:23:11 人评论 次浏览
  • 1047 编程团体赛 很基础的题

    注意点 输入为数字掺杂字符时,用scanf会比较方便 代码 #include <iostream> #include <cstdio>using namespace std;int a[1002]; int main(){for(int i=0;i<1002;i++){a[i]=0;}int n;int max=-1;int maxi;int index,t,grade;scanf("%d",&n…

    2022/7/10 1:21:21 人评论 次浏览
  • C++11特性小结

    一、关键字(1)新增关键字:thread_local、static_assert、nullptr、noexcept、decltype、constexpr、char32_t、char16_t、alignof、alignasthread_local:实现了线程局部存储,让每个线程都独立访问数据,互不干扰;thread_local 标记的变量在每个线程里都会有一个独立…

    2022/7/10 1:21:17 人评论 次浏览
  • 智能指针思想实践(std::unique_ptr, std::shared_ptr)

    1 smart pointer 思想 ​ 个人认为smart pointer实际上就是一个对原始指针类型的一个封装类,并对外提供了-> 和 * 两种操作,使得其能够表现出原始指针的操作行为。 ​ 要理解smart pointer思想首先要了解一个概念RAII(Resource Acquisition Is Initialization), 直…

    2022/7/9 23:20:26 人评论 次浏览
  • 牛客小白月赛53

    牛客小白月赛53 第二次打妞妞月赛 三题下班,呜呜呜我好菜orz https://ac.nowcoder.com/acm/contest/11230 A. Raining 按照题意模拟即可 #include <bits/stdc++.h>using namespace std;int main () {int a, b, c, d, x;cin >> a >> b >> c >&…

    2022/7/8 23:52:42 人评论 次浏览
扫一扫关注最新编程教程