![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
技巧
zhiaifangao
这个作者很懒,什么都没留下…
展开
-
ACM 简单模板 差分
(1) 一维差分 for (i=1; i<=n; i++) { scanf("%d", &data[i]); diff[i] = data[i] - data[i-1]; } for (i=0; i<m; i++) { int l, r, c; scanf("%d%d%d", &l, &r, &c); diff[l] += c; diff[r+1]原创 2020-10-31 09:46:27 · 235 阅读 · 0 评论 -
各种小技巧模板 最大连续子区间 exgcd 大数乘法 二分(持续更新)
最大连续子区间(和) ans = lst = 0; for(i = 0; i < n; ++i){ lst = max(0, lst) + a[i]; //lst = max(lst+a[i], a[i]); ans = max(ans, lst); }原创 2020-09-08 18:59:33 · 225 阅读 · 1 评论 -
__int128 爆long long 了就用它
听说 linux 环境下才能用,,,输入输出的板子#include <bits/stdc++.h>using namespace std;inline __int128 read(){ __int128 x = 0, f = 1; char ch = getchar(); while (ch<'0' || ch>'9') { if (ch == '-') f = -1; ch = ge原创 2020-08-03 19:06:20 · 931 阅读 · 1 评论 -
HDU 1563 Find your present! 异或妙用找到独立出现的数
Problem DescriptionIn the new year party, everybody will get a “special present”.Now it’s your turn to get your special present, a lot of presents now putting on the desk, and only one of them will be yours.Each present has a card number on it, and your p原创 2020-07-19 12:26:10 · 141 阅读 · 0 评论 -
CodeForces - 1343D Constant Palindrome Sum 分情况讨论+差分
You are given an array a consisting of n integers (it is guaranteed that n is even, i.e. divisible by 2). All ai does not exceed some integer k.Your task is to replace the minimum number of elements (replacement is the following operation: choose some ind原创 2020-07-08 10:14:40 · 164 阅读 · 0 评论 -
含空格字符串的输入+字符串相关函数
可以输入空格char str[36];gets(str) ;char str[30];cin.getline(str, 30);string str;getline(cin, str);遇到换行结束, 其后不用再加一个 getchar() 吸收前面的输入是cin>>ss;的话,那么此处str的值时空的,因为他会读取上一行的结束符所以前面加一个 getchar() 吸收...原创 2020-04-30 21:35:47 · 449 阅读 · 0 评论 -
根据数据范围推测实践复杂度及算法
一般ACM或者笔试题的时间限制是1秒或2秒。在这种情况下,C++代码中的操作次数控制在 107107 为最佳。下面给出在不同数据范围下,代码的时间复杂度和算法该如何选择:n≤30n≤30, 指数级别, dfs+剪枝,状态压缩dpn≤100n≤100 => O(n3)O(n3),floyd,dpn≤1000n≤1000 => O(n2)O(n2),O(n2logn)O(n2lo...转载 2020-02-11 09:17:15 · 397 阅读 · 0 评论