ICode9

精准搜索请尝试: 精确搜索
  • P3959 [NOIP2017 提高组] 宝藏 --状态压缩dp,dfs2022-07-15 23:33:25

            #include <bits/stdc++.h> #define dbg(x) std::cerr << #x << "=" << x << "\n" using i64 = long long; constexpr int N = 15; int n, m, lim, ans = 2e9, G[N][N]; int dis[N],f[N][1 << N][N]; void

  • 1107 老鼠爱大米 较简单2022-07-15 23:33:07

    代码 #include <iostream> #include <cstdio> using namespace std; int main() { int n,m; int w; int maxw; int maxmaxw=-11; cin>>n>>m; for(int i=0;i<n;i++){ maxw=-1; for(int j=0;j<m;j++){ cin>>w; if(maxw<w

  • terminate called after throwing an instance of ‘std::logic_error‘错误修改方法2022-07-15 22:32:14

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

  • PAT乙级 1002 写出这个数 C++2022-07-15 15:38:20

    //读入一个正整数 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 cnt = 0; std::cin >> num;

  • 因数2022-07-15 13:33:56

    因数的个数 求一个数的全部因数 #include<bits/stdc++.h> using namespace std; vector<int> a; bool yin(int x){ for(int i = 1; i*i <= x; i++){ if(x%i == 0){ a.push_back(i); if(i!=x/i)a.push_back(x/i); } } } int main(){ int x; cin >>

  • 1101 B是A的多少倍 较简单2022-07-15 10:04:50

    代码 #include <iostream> #include <cstdio> #include <string> #include <iomanip> using namespace std; int main() { string a; int d; string b; cin>>a>>d; d=a.size()-d; b=a; for(int i=0;a[i]!=NULL;i++){ if(i+d<=

  • 1098 岩洞施工2022-07-14 22:38:40

    代码 #include <iostream> #include <cstdio> using namespace std; int tmpb[101]; int main() { int n; int a; int mina=1001; int b; int maxb=-1; cin>>n; for(int i=0;i<n;i++){ cin>>a; if(mina>a){ mina=a; } } for(

  • P1892团伙 -- 并查集datastructure2022-07-14 20:31:07

    #include <bits/stdc++.h> using i64 = long long; int fa[1000005],b[1000005]; int find(int x){ return (fa[x] == x ? x : (fa[x] = find(fa[x]))); } void merge(int x,int y){ fa[find(x)] = find(y); } int main(){ std::ios::sync_with_stdio(fal

  • Codeforces 704 D2022-07-14 15:05:12

    这题有一些前置知识:有源汇有上下界最大流。 首先,如果\(r<b\),那么我们希望\(r\)更多;否则我们希望\(b\)更多。其实如果\(r<b\),那么我们可以将\(r\)看成\(1\),\(b\)看成\(0\),目标是那么我们相当于将贡献从\(r\)和\(b\)变成了\(0\)和\(1\)。 那么考虑一个有上下界的最大流: 我们对于每行

  • 1094 谷歌的招聘2022-07-14 14:00:19

    错误点 2是素数。。。这一处考虑错了 代码 #include <iostream> #include <cstdio> #include <string> using namespace std; bool is_nature(long long a){ if(a==1||a==0){ return 0; } if(a==2){ return 1; } else if(a%2==0){ return 0; } for(long long i=3

  • C++(17):filesystem2022-07-13 20:34:40

    C++17将文件系统的操作封装了进来,从而可以跨平台的操作文件系统: #include <iostream> #include <fstream> #include <cstdlib> #include <filesystem> using namespace std::filesystem; int main() { create_directories("./sandbox/a/b"); //在当前目录下创建层级目录san

  • 「2017 山东一轮集训 Day6」子序列2022-07-13 20:03:17

    复盘 \(\color{black}{\text{c}}\color{red}{\text{yx}}\) 讲的题,我是不会告诉你我不知道他网名的。 这可以来一手反复鞭尸( Description 区间本质不同子序列,母串长度 \(n\) ,询问 \(q\) 次,字符集大小 \(|\sum|\) 。 \(n,\ q\leq 10 ^ 5,\ |\sum| \leq 9\) Analysis 本来还有一个区

  • 不定参数模板类2022-07-13 18:33:55

    #include <iostream> #include <tuple> using namespace std; template<class... Args> class student{ public: template<typename HEAD> void displayParam(const HEAD &head){ } void displayParam(){

  • C++ reserve和resize的区别2022-07-13 16:01:02

    前置知识: capacity是指容器的容量,指该容器如果不重新分配内存,最多只能容纳capacity个元素。 size是指容器中当前存在的元素个数。 capacity和size的关系:size <= capacity   reserve(n)是指为容器至少预分配n * sizeof(元素)的容量。如果分配的n<size,则不会起作用。 std::vec

  • 我的马蜂2022-07-13 14:03:07

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

  • 1084 外观数列 较简单2022-07-13 12:31:05

    代码 #include <iostream> #include <cstdio> #include <cmath> using namespace std; int r[10001]; int main() { int n; int a; for(int i=0;i<10001;i++){ r[i]=0; } cin>>n; for(int i=0;i<n;i++){ cin>>a; r[abs(i+1-a)

  • Codeforces Round 114 (Div. 3) 题解2022-07-13 08:01:52

    A - 114 我们知道 11*4+5*14=114, 所以直接输出 11,4,5,14 即可 #include<bits/stdc++.h> using namespace std; int mian(){ print(11,' ',4, ' ',5 , ' ', 1, ' ', 4); print(std::endl); } B - 514 跟一个一个一个一个第一题一样,是考虑用 114514 凑出来 514

  • 1076 Wifi密码 较简单2022-07-12 20:01:07

    代码 #include <iostream> #include <cstdio> #include <string> using namespace std; int main() { string s; int n; cin>>n; getchar(); for(int i=0;i<n;i++){ getline(cin,s); for(int j=0;s[j]!=NULL;j++){ if(s[j]=='T�

  • 2-SAT模板2022-07-12 01:02:12

    K #include <iostream> #include <cstdio> using namespace std; const int N = 30010; int n, m, head[N], ver[N << 1], nex[N << 1], tot, dfn[N], colCnt, col[N], sta[N], top, vis[N], low[N], cnt, ans[N]; inline void add (int x, int y) {

  • 1063 计算谱半径 较简单2022-07-11 20:09:30

    注意点 开方用到cmath 代码 #include <iostream> #include <cstdio> #include <cmath> #include <iomanip> using namespace std; int main() { int n; int a,b; float tmp; float max=-1; cin>>n; for(int i=0;i<n;i++){ cin>>a>&g

  • Codeforces Round #805 (Div. 3) 题解2022-07-11 02:02:37

    A. Round Down the Price AC代码 #include <bits/stdc++.h> #define IOS \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); \ std::cout.tie(0); using PII = std::pair<int, int>; using ll =

  • Codeforces Round #805 (Div. 3)2022-07-11 02:01:47

    咕咕咕咕。 E. Split Into Two Sets 题意 有\(n\)张牌,每张牌上写有两个数字,问是否能将牌分成两个集合,使得单个集合中的牌上的数字构成的集合没有重复元素。 其中\(2 \le n \le 2 \times{10}^5\)。 思路 转化成图论问题,令每个数字对应一个节点,问题从将牌分成两个集合转换成将数

  • 必须用 std::function<> 而不能用指针的一个场景2022-07-10 17:02:16

    《C++高级编程》第4版 18.2节 可以指向任何可调用对象:函数、函数对象、或 lambda 表达式;被称为多态函数包装器,可以当成函数指针使用,还用作实现回调函数的参数。function 真正有用的场合是将回调函数作为类的成员变量。 必须用 std::function<> 而不能用指针 如果 process 函数的

  • STL的速度实验2022-07-10 13:32:11

    拿个单调队列的题做试验: 使用STL的代码 #include<bits/stdc++.h> using namespace std; const int N=2e5+10; int n,m,x,f[N]; deque<int>q; int main(){ freopen("test.in","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i

  • 智能指针思想实践(std::unique_ptr, std::shared_ptr)2022-07-09 19:02:19

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

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

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

ICode9版权所有