自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 Codeforces 895B (stl binary search)

想好左右界,以及边界可以整除的情况。 注意,左界可能存在小于ai的情况,这种是不合法的。/** 20171128*/#include <cstdio>#include <algorithm>using namespace std;#define maxn 100010int n;long long x,k;long long num[maxn];int main(){ scan

2017-11-27 14:44:05 360

原创 Codeforces 895A (入门 prefix sum)

/** 20171128*/#include <cstdio>#include <algorithm>int n;int num[400];int prefixSum[400];int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&num[i]); pr

2017-11-27 12:36:10 398

原创 N个数划分两组,差最小

思路,01背包解决,复杂度O(w*n)/** 20171127*/#include <cstdio>#include <cstring>#include <algorithm>int n;int num[400];int dp[200][400];//w nint main(){ memset(dp,0,sizeof(dp)); scanf("%d",&n);

2017-11-27 12:22:54 3669

原创 图论问题

正向做,求一棵带权树任意两点间的距离,思路暴力搜索。 反向做,求一个矩阵是否为一个棵带权树,思路先做最小生成树,然后dfs判定。

2017-11-25 19:42:46 446

原创 Codeforces 371D (Union-find)

并查集做,满了的水池合并为为最后一个为父节点#include <cstdio>#include <algorithm>#include <cstring>#include <cstdlib>#define maxn 200010int n;int next[maxn];int v[maxn];int lft[maxn];/*union-findsomewhere change to

2017-11-25 17:54:30 337

原创 My Templet

线段树:/*#define maxn 1000005int gnode[maxn];long long gnum[maxn*4];the segment gnum must full binary tree,the left child is loc*2+1,and the right child is loc*2+2.*/void GxdSegmentTreeAdd(long long

2017-11-25 16:04:27 434

原创 Uva 253 (implement)

/** 20171119*/#include <cstdio>#include <cstring>int e[10][10];int main(){ //freopen("input.txt","r",stdin); //freopen("ans.txt","w",stdout); memset(e,0,sizeof(e)); e[1][2] = e[2][1

2017-11-19 23:17:23 267

原创 Mac:Abort trap:6

scanf数组超界

2017-11-19 23:11:04 8051 1

原创 C/C++:计算器

支持加,减,乘,除,嵌套小括号,正整数阶乘。/** 20171111*/#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#define eps 0.00001const char s[] = {'(',')','+','-','*','/','^'};struct Node{ char t

2017-11-11 20:31:53 457

原创 Shell:syntax error near unexpected token

在终端使用自己写的小工具时, 自己写的命令后面的参数最好不要有保留字符: 例如‘*’表示匹配当前路径下所有文件名,而不是自己所想的乘号。 例如‘(’会报错‘syntax error near unexpected token’。

2017-11-11 19:58:28 567

原创 C++ 指针和引用

指针肯定是占用存储空间的。 但关于引用占用空间: C++语言ISO标准文档2003,8.3.2第三条:It is unspecified whether or not a reference requires storage(3.7) 具体占用空间根据编译器来决定。const 不能用于引用。 引用只能引用一级(或一次)。 sizeof引用得到的是所指对象的大小。 指针可以为空,引用在定

2017-11-10 20:21:48 218

原创 Mac 快捷键

Mac下sublime3快捷键 Command + 左右方向键 == home 和 end键 Command or fn + 上下方向键 == pageup 和 pagedown Option + 左右方向键 == 以单词为单位前后移动

2017-11-10 19:26:05 272

原创 UVa 220 (implement)

找到了一个小bug,就是输出坐标时,会重复输出,后来加了getout控制就AC了。 写模拟题思维一定要严谨,代码严谨已读很重要/** 20171109*///#define LOCAL#include <cstdio>#include <cstring>#include <algorithm>#include <map>using namespace std;int dx[] = {-1

2017-11-09 19:23:00 416

原创 UVa 201 (implement)

/** 20171109*///#define LOCAL#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int num[10][10][10][10];int ans[10];int n;bool hline(int x,int y,int dx,int dy,int k){

2017-11-09 15:45:50 238

原创 UVa 1589 (implement)

思维失误了,是红子可以被吃掉,但被另外一个红字管辖就不能被吃。/** 20171108*///#define LOCAL //#define TEST#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int dx[] = {1,-1,-2,-2,-1,1,2,2};const

2017-11-08 15:07:40 240

原创 Uva12412 (implement)

这里有个非常非常注意的点:对于浮点数运算,首先十分推荐用double,然后如果出现浮点数保留几位小数的情况,一定要在执行保留小数前另外加eps(精度容错)/** 20171104*/#include <cstdio>#include <cstring>using namespace std;#define maxn 10000#define eps 0.00001const char fna

2017-11-04 20:52:52 504

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除