This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "dynamic_battlefog.h" | |
#include <cmath> | |
#include <set> | |
#include <map> | |
#include <assert.h> | |
#include <algorithm> | |
using std::max; | |
using std::min; | |
CDynamicBattleFog::CDynamicBattleFog() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
#include <assert.h> | |
using namespace std; | |
vector<int> getLeftMin(const vector<int> &vecAll) | |
{ | |
vector<int> vecMin; | |
if (!vecAll.empty()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
#include <ext/hash_map> | |
#include <algorithm> | |
using namespace std; | |
using namespace __gnu_cxx; | |
typedef pair<int,int> pairii; | |
int max_consecutive_sequence_len(const vector<int> &vecArray) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;http://acl.readthedocs.org/en/latest/zhCN/ch5-cn.html#chapter-5-exercises | |
;定义一个接受一系列数字的函数,并在若且唯若每一对(pair)数字的差为一时,返回真,使用 | |
;(a) 递归 | |
;(b) do | |
(defun linked-r (lst) | |
(or (null lst) | |
(null (cdr lst)) | |
(and (diff-1 (car lst) (cadr lst)) | |
(linked-r (cdr lst))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; http://acl.readthedocs.org/en/latest/zhCN/ch5-cn.html#chapter-5-exercises | |
; 5.7-c | |
; 定义一个接受一系列数字的函数,并在若且唯若每一对(pair)数字的差为一时,返回真,使用mapc 与 return。 | |
(defun linked-mapc (lst) | |
(mapc #'(lambda (x y) | |
(unless (diff-1 x y) | |
(return-from linked-mapc nil))) | |
lst (cdr lst)) | |
t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A丢100个6面骰子,B丢160个4面骰子。那么A的点数总和比B的点数总和大的几率以及相等的几率分别该怎么计算? | |
http://weibo.com/2039631434/zaMYL2jOj | |
*/ | |
#include <cstdio> | |
#include <cassert> | |
template<int n,int dice> | |
double f(int d) | |
{ |