ICode9

精准搜索请尝试: 精确搜索
  • 皇宫看守2022-09-16 22:32:58

    原题链接 树形DP + 状态机 对于每个节点u有三种情况: 1.u点放置哨兵,u被自己观察到,那么u的子节点可放可不放,取min 2.u不放哨兵,但是u的任一子节点放置了哨兵,u被子节点观察到 3.u不放哨兵,u的父节点放置了哨兵,u被父节点观察到,那么u的子节点可放可不放 所以状态机定义三种模型 状态表示:

  • c++11 为什么使用ref,和引用的区别2022-09-16 18:33:54

    std::ref只是尝试模拟引用传递,并不能真正变成引用,在非模板情况下,std::ref根本没法实现引用传递,只有模板自动推导类型时,ref能用包装类型reference_wrapper来代替原本会被识别的值类型,而reference_wrapper能隐式转换为被引用的值的引用类型。 std::ref主要是考虑函数式编程(如std::bi

  • C++11之std::future对象使用说明2022-09-16 18:01:09

    std::future介绍 在前面几篇文章中基本都用到thread对象,它是C++11中提供异步创建多线程的工具。但是我们想要从线程中返回异步任务结果,一般需要依靠全局变量;从安全角度看,有些不妥;为此C++11提供了std::future类模板,future对象提供访问异步操作结果的机制,很轻松解决从异步任务中返

  • 求答疑2022-09-15 15:30:35

    #include<bits/stdc++.h> using namespace std; int x; int main() { for(int i=1;i<=10;++i) { x++; cout<<x<<endl; } int x=100-x; cout<<x<<endl; return 0; } 运行结果: 1 2 3 4 5 6 7 8 9 10 99 把程序改为: #include<bits/std

  • 1. 两数之和2022-09-15 10:04:33

    1. 两数之和 力扣题目链接(opens new window) 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 示例: 给定 nums = [2, 7, 11, 15], targe

  • 实现SM4算法(16字节版)2022-09-14 09:34:12

    base_sm4.h #pragma once #include <vector> #include <iostream> /*32位以内的循环左移*/ #define SM4_Rotl32(buf,n) (((buf)<<(n))|((buf)>>(32-(n)))) class base_sm4 { public: base_sm4() {}; /* * 函数SM4_SelfCheck是SM4自检函数,它用标准数据作为输入,

  • 实现SM4-ECB、CBC、CFB、OFB算法(大数据版)2022-09-14 09:31:03

    base_sm4类参考: 实现SM4算法(16字节版) sm4.h #pragma once #include <algorithm> #include <iostream> #include "D:\C++\实现SM4算法(16字节版)\base_sm4.h" constexpr bool SM4_ENCRYPT = 1; //进行加密运算 constexpr bool SM4_DECRYPT = 0;

  • 024:这是什么鬼delete2022-09-13 23:03:55

    1 #include <iostream> 2 using namespace std; 3 class A 4 { 5 public: 6 A() { } 7 virtual ~A() { cout << "destructor A" << endl; } 8 }; 9 class B:public A { 10 public: 11 ~B() { cout << "de

  • 5 份代码,让你彻底搞懂 std::swap() 在干嘛2022-09-12 14:32:25

    1 int a,b,*c,*d; signed main(){ios::sync_with_stdio(false),cin.tie(nullptr); a=1,b=2; c=&a,d=&b; cout<<a<<" "<<b<<" "<<*c<<" "<<*d<<endl; swap(a,b); cout<<a&l

  • 511 试除法 判质数2022-09-12 11:34:20

    视频链接: Luogu P5736 【深基7.例2】质数筛 #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; bool isprime(int x){ //判质数 if(x == 1) return 0; for(int i=2; i<=sqrt(x); i++) if(x%i == 0)

  • 11.拷贝构造函数2022-09-12 11:02:06

    #include <iostream> using namespace std; class Maker { private: int a; public: Maker() { cout << "无参构造函数" << endl; a = 20; } //拷贝构造函数 Maker(const Maker &m) { cout <<

  • 12.构造函数的分类及调用2022-09-12 11:00:51

    //2022年9月9日09:21:51 #include <iostream> using namespace std; class Maker { public: //按照参数分类 Maker() { cout << "无参构造" << endl; } Maker(int a) { cout << "有参构造" << end

  • 13.匿名对象2022-09-12 11:00:08

    //2022年9月9日09:54:59 #include <iostream> using namespace std; class Maker { public: Maker() { cout << "无参构造函数" << endl; } Maker(int a) { cout << "有参构造函数" << endl; }

  • C++ 第9课字符三角形2022-09-11 22:02:54

    #include <iostream> #include <string> using namespace std; int main(int argc, char** argv) { char a; cout<<"请输入一个字符:"; cin>>a; cout<<" "<<a<<endl; cout<<" "<<a<&

  • C++ 第13课输出九九乘法表2022-09-11 22:01:17

    #include <iostream> using namespace std; int main(int argc, char** argv) { int a = 1; for(int c = 1;c<10;c++){ for(int d = 0;d<9;d++){ cout<<a+d<<"x"<<c<<"="<<(a+d)*c<<"\t&qu

  • C++ 第40课转进制2022-09-11 21:30:22

    #include <iostream> #include <string> using namespace std; int main() { /*string a; int p = 1; int s = 0; cout<<"请输入一个二进制数:"; cin>>a; for(int i = a.length()-1;i>=0;i--){ int x = a[i]-�

  • 水仙花数2022-09-11 19:31:22

    输出100~999中的所有水仙花数。若3位数ABC满足A3 + B3 + C3,则称其为水仙花数。 #include<iostream> #include<cmath> using namespace std; int main() { for(int i=100; i<=999; i++) { int h = i/100; int m = i/10%10; int l = i%10;

  • MC钻石铲代码2022-09-11 18:32:14

    #include <iostream> #include <string> #include <Windows.h> #include "minecraft.h" using namespace std; TxMinecraft tongxin; int main(int argc, char** argv) { cout<<"准备开始"<<endl; string Server="tk.ma

  • C++ 第一课钻石铲代码2022-09-11 18:30:08

    #include <iostream> #include <string> #include <Windows.h> #include "minecraft.h" using namespace std; TxMinecraft tongxin; int main(int arcg,char**argv){ cout<<"准备开始"<<endl; string Server = "tk.mak

  • C++学习笔记-day132022-09-11 13:33:50

    1、多态的基本概念   #include<iostream> using namespace std; //多态 class Animal { public: //虚函数 virtual void speak() { cout << "动物在说话" << endl; } }; //猫类 class Cat :public Animal { public: void speak()

  • C++STL笔记2022-09-10 11:03:45

    STL学习笔记 参考文档: https://cplusplus.com/reference/ https://zh.cppreference.com/w/首页 https://docs.microsoft.com/en-us/cpp/standard-library/cpp-standard-library-reference?view=msvc-170 https://github.com/huihut/interview 总体总结 容器分类 容器复合

  • std::bind绑定unique_ptr2022-09-08 18:30:49

    问题的来源,绑定和unique_ptr std::bind绑定unique_ptr的时候生成的类型并非std::function,而是一个不可拷贝的类型,这跟unique_ptr的特性有关,这意味着如果需要暂时保存绑定的函数,没有能够接受对象的类型声明 如果不需要保存可以使用auto来接受绑定的对象,然后调用 void Test(int val

  • std::map find和count用法说明2022-09-08 11:33:04

    Map: 在使用标准模板库中的map容器且遇到键值对的值为自定义struct或class类型时,考虑到特殊场景(即不能确保key自始至终唯一),若插入新元素(new 对象),在程序执行结束释放内存时会造成内存泄露(重复的key对应的value所申请的内存空间)。  因此在插入新元素前需要判断key是否已经存在,若存

  • 基础前缀和2022-09-07 11:02:45

    https://www.acwing.com/problem/content/797/ #include<cstring> #include<algorithm> #include<cstdio> #include<iostream> using namespace std; const int N = 1e5+5; int n,m,l,r; int a[N],s[N]; int main() { cin >> n >> m; f

  • 1151:素数个数2022-09-05 22:32:48

    编程求2-n中有多少个素数。 #include <iostream>using namespace std;int main(){    int n,s=0,sum=0;    cin>>n;    for(int i=2;i<=n;++i)    {        s=0;        for(int j=2;j<=i-1;++j)        {            if(i%j==0)     

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有