May 6

cpp.vim

" Vim syntax file
" Language:	C++ special highlighting for STL classes and methods
" Maintainer:	Nathan Skvirsky
" Last Change:	2006 Oct 22

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" Read the C syntax to start with
if version < 600
  so <sfile>:p:h/c.vim
else
  runtime! syntax/c.vim
  unlet b:current_syntax
endif

"========================================================
" Highlight All Function
"========================================================
syn match   cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match   cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi cFunction        gui=NONE guifg=#B5A1FF

"========================================================
" Highlight All Math Operator
"========================================================

" Math Operator
hi cMathOperator            guifg=#3EFFE2
hi cPointerOperator         guifg=#3EFFE2
hi cLogicalOperator         guifg=#3EFFE2
hi cBinaryOperator          guifg=#3EFFE2
hi cBinaryOperatorError     guifg=#3EFFE2
hi cLogicalOperator         guifg=#3EFFE2
hi cLogicalOperatorError    guifg=#3EFFE2

" C++ extentions

syn match   cppFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match   cppFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1

syn keyword cppSTL		abort abs accumulate acos adjacent_difference adjacent_find adjacent_find_if any append asctime asin assert assign at atan atan2 atexit atof atoi atol auto_ptr back back_inserter bad bad_alloc bad_cast bad_exception bad_typeid badbit beg begin binary_compose binary_negate binary_search bind2nd binder1st binder2nd bitset bsearch c_str calloc capacity ceil cerr cin clear clearerr clock clog close compare compose1 compose2 const_iterator construct copy copy_backward copy_n cos cosh count count_if cout ctime data deque destroy difference_type difftime div divides domain_error empty end endl eof eofbit equal equal_range erase exception exit exp fabs fail failbit failure fclose feof ferror fflush fgetc fgetpos fgets fill fill_n find find_end find_first_not_of find_first_of find_if find_last_not_of find_last_of first flags flip floor flush fmod fopen for_each fprintf fputc fputs fread free freopen frexp front fscanf fseek fsetpos fstream ftell fwrite gcount generate generate_n get get_temporary_buffer getc getchar getenv getline gets gmtime good goodbit greater greater_equal hash_map hash_multimap hash_multiset hash_set ifstream ignore in includes inner_product inplace_merge insert inserter invalid_argument ios ios_base iostate iota is_heap is_open is_sorted isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace istream istream_iterator istringstream isupper isxdigit iter_swap iterator iterator_category key_comp ldiv length length_error less less_equal lexicographical_compare lexicographical_compare_3way list localtime log log10 logic_error logical_and logical_not logical_or longjmp lower_bound make_heap malloc map max max_element max_size mem_fun mem_fun1 mem_fun1_ref mem_fun_ref memchr memcpy memmove memset merge min min_element minus mismatch mktime modf modulus multimap multiplies multiset negate next_permutation npos nth_element numeric_limits ofstream open ostream ostream_iterator ostringstream out_of_range overflow_error pair partial_sort partial_sort_copy partial_sum partition peek perror plus pointer pointer_to_binary_function pointer_to_unary_function pop pop_back pop_front pop_heap pow power precision prev_permutation printf ptr_fun push push_back push_front push_heap put putback putc putchar puts qsort raise rand random_sample random_sample_n random_shuffle range_error rbegin rdbuf rdstate read realloc reference remove remove_copy remove_copy_if remove_if rename rend replace replace_copy replace_copy_if replace_if reserve reset resize return_temporary_buffer reverse reverse_copy reverse_iterator rewind rfind rotate rotate_copy runtime_error scanf search search_n second seekg seekp set set_difference set_intersection set_symmetric_difference set_union setbuf setf setjmp setlocale setvbuf signal sin sinh size size_t size_type sort sort_heap splice sprintf sqrt srand sscanf stable_partition stable_sort std str strcat strchr strcmp strcoll strcpy strcspn strerror strftime string strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtod strtok strtol strtoul strxfrm substr swap swap_ranges sync_with_stdio system tan tanh tellg tellp temporary_buffer test time time_t tmpfile tmpnam to_string to_ulong tolower top toupper transform unary_compose unary_negate underflow_error unget ungetc uninitialized_copy uninitialized_copy_n uninitialized_fill uninitialized_fill_n unique unique_copy unsetf upper_bound va_arg value_comp value_type vector vfprintf vprintf vsprintf width write

syn keyword cppStatement	new delete this friend using
syn keyword cppAccess		public protected private
syn keyword cppType		inline virtual explicit export bool wchar_t
syn keyword cppExceptions	throw try catch
syn keyword cppOperator		operator typeid
syn keyword cppOperator		and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
syn match cppCast		"\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1
syn match cppCast		"\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
syn keyword cppStorageClass	mutable
syn keyword cppStructure	class typename template namespace
syn keyword cppNumber		NPOS
syn keyword cppBoolean		true false
syn match cppMathOperator         "[-+\*/%=]"
syn match cppPointerOperator      "->\|\."
syn match cppLogicalOperator      "[!<>]=\="
syn match cppLogicalOperator      "=="
syn match cppLogicalOperator      "&&\|||"
syn match cppLogicalOperatorError "\(&&\|||\)="
syn match cppBinaryOperator       "\(&\||\|\^\|<<\|>>\)=\="
syn match cppBinaryOperator       "\~"
syn match cppBinaryOperatorError  "\~="

" The minimum and maximum operators in GNU C++
syn match cppMinMax "[<>]?"

" Default highlighting
if version >= 508 || !exists("did_cpp_syntax_inits")
  if version < 508
    let did_cpp_syntax_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif
  HiLink cppAccess		cppStatement
  HiLink cppCast		cppStatement
  HiLink cppMathOperator	cppStatement
  HiLink cppPointerOperator	cppStatement
  HiLink cppLogicalOperator	cppStatement
  HiLink cppLogicalOperatorError	cppStatement
  HiLink cppBinaryOperator	cppStatement
  HiLink cppBinaryOperatorError	cppStatement
  HiLink cppExceptions		Exception
  HiLink cppOperator		Operator
  HiLink cppStatement		Statement
  HiLink cppSTL			Identifier
  HiLink cppFunction		Identifier
  HiLink cppNCBI		Special
  HiLink cppType		Type
  HiLink cppStorageClass	StorageClass
  HiLink cppStructure		Structure
  HiLink cppNumber		Number
  HiLink cppBoolean		Boolean
  delcommand HiLink
endif

let b:current_syntax = "cpp"

" vim: ts=8.vimrc

.vimrc

set helplang=cn

set encoding=utf-8

set fenc=utf-8
set fencs=utf-8,gb2312,ucs-bom,gb18030,gbk,cp936,big5

set tabstop=8
set shiftwidth=8

filetype plugin indent on
set completeopt=longest,menu

syntax enable
syntax on

colorscheme desert

let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>

:set cscopequickfix=s-,c-,d-,i-,t-,e-

let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplMapWindowNavVim = 1

nnoremap <silent> <F12> :A<CR>
nnoremap <silent> <F3> :Grep<CR>
map <F7> :!g++ % -o %:r
May 4

Chrome在Linux下字体设置总是不对,原因是新版的设置页面的Bug。

需要用启动选项:

-disable-tabbed-options

来开启旧版设置,或者在任何一个页面输入处“右键——拼写检查选项——语言设置——字体和编码”就可以正确设置了。

Apr 17
int[] inv = new int[MAXN];
inv[1] = 1;
for (int i = 2; i<MAXN; i++)
    inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;

注意这里的MOD必须是素数。

摘自TopCoder上某人的代码。

Nov 30
  • log1p(x)=log(1+x):看似是一个丝毫没有用的函数,但是如果x非常之小,问题就会出现。计算机会把1+x的结果计算为1,然后返回了0,这和实际结果的相对误差实在太大。
  • expm1(x)=exp(x)-1:存在的理由和上面一样。
  • erfc(x)=1-erf(x):erf()是一个计算误差的函数,当x很大的时候,erf(x)约为1,此时1-erf(x)就会被计算为0,但它的值应该是一个正数。

转自:HACKER MONTHLY Issue 3 August by John D. Cook

Oct 31

杭州赛区我们基本上没有犯什么严重的错误,但是反映了一个问题:代码速度太慢。个人觉得这次杭州的题目出的不错,不像Tianjin那样容易变得没有梯度,也不想Harbin那样只有2道难题。这次比赛一共有6道相对简单的题目,剩下的题目都是需要一定时间去做的。

比赛流程还是老样子,我全程都在读题,讲解题目意思。肖刘看完J之后觉得可以写,而我有没有发现什么一下子就可以写的题目,于是就让肖刘先写了。肖刘不负众望,1Y,这种递推、DP的题目肖刘还是很擅长的。然后我们讨论了一下所有题目的意思,觉得还是先写C和H,我轻松1Y了C,李晔晨也1Y了H。这时候已经有队伍4道题了。我们选择了跟一下题目,于是目前可以做的题目就是D、F。我们先写了F,WA了1次之后AC了。然后我们讨论了一下B,觉得是可以做的,于是就上去写,虽然中间犯了很多错误,但是还是AC了。接着我又和肖刘想出了D的算法,最后成功AC。期间李晔晨一直在调试E,未果。

本次比赛比较可惜的是,我们会G的算法,但是没有时间写了。而且I的算法也只差一点就想到了。时间不够用的原因就是代码能力不够,希望以后可以加强这方面的能力,再接再厉。