Common Knowledge
2014-08-23 11:01:11
-6:四面体
(1)内切球半径:r = 3V / (S1+S2+S3+S4)
(2)体积:将四点组成三个向量AB,AC,AD,向量的混合积就是它们组成的平行六面体的体积,四面体体积是其体积的1/6。

-5:枚举一个集合(设为s)的所有超集,总共N个物品。(ts为集间差)
for(int f = s; f < ( << N); f = (f + ) | s){
int ts = s ^ f;
}
-4:枚举一个集合(设为s)的所有非空子集,总共N个物品。(ts为集间差),注意空集需要另外讨论。
for (int f = s; f > ; f = (f - ) & s) {
int ts = s ^ f;
}
-2:头文件便利贴(C++11)
#include <bits/stdc++.h>
using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-;
const int INF = ( << ) - ;
const int MAXN = ; int main(){ return ;
}
-3:头文件便利贴
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-;
const int INF = ( << ) - ;
-1:vim配置文件
set nu ci si ai mouse=a ts= sts= sw= cursorline
0:数论
(1)计算比m小,且与m互质的的正整数的和:phi(m)*m/2
(2)计算比m小,且与m不互质的正整数的和:(phi(m)+1)*m/2
(3)同余符号: ≡
(4)1和任何数都成倍数关系,但和任何数都互质。
1:运算符优先级

2:素数定理

3:反素数表
1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,7560,10080,15120,20160,25200,27720,45360,50400,55440,83160,110880,166320,221760,277200,332640,498960,554400
4:点旋转坐标公式:
任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:
x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;
y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;
5:快速读入:
inline int Read(){
int x = ,f = ;char ch = getchar();
while(ch < '' || ch > ''){if(ch == '-')f = -;ch = getchar();}
while(ch >= '' && ch <= ''){x = x * + ch - '';ch = getchar();}
return x * f;
}
6:关闭C++读入同步
ios::sync_with_stdio(false);
7:快速输出:
void Write(int v){
if(v>) Write(v/);
putchar(v%+'');
}
8:正无穷
(1)int型边界:const int INF = ~0U >> 1;
9:简洁的组合数打表(from wjmzbmr):
for (int i = ; i < ; ++i) {
for (int j = ; j <= i; ++j) {
comb[i][j] =
(i == || j == ) ?
: (comb[i - ][j] + comb[i - ][j - ]);
}
}
10:循环版求gcd(from tourist)
int gcd(int a, int b) {
while (a > && b > )
if (a > b) a %= b;
else b %= a;
return a + b;
}
11:atoi 和 itoa 函数 参考:博文
● atoi():将字符串转换为整型值。
● atol():将字符串转换为长整型值。
● itoa():将整型值转换为字符串。
● ltoa():将长整型值转换为字符串。
12:卡哈希
参考bzoj题目
13:unique函数的一些注意点:
数组下标从0开始:int sz = unique(a,a + n) - a;
数组下标从1开始:int sz = unique(a + 1,a + n + 1) - a - 1;
14:生成 long long 范围 内的随机数:(不确定是否正确)
val = ((ll)rand() << ) + ((ll)rand() << ) + ;
15:快速预处理阶乘逆元
先求出 (MAXN - 1)! 的逆元,然后倒序依次求出:(MAXN - 2)! ~ 1! 的逆元
注意:如果MAXN - 1 >= mod,那么不能直接这么用。因为 fac[mod] % mod = 0
int fac[MAXN],afac[MAXN];
int Q_pow(int x,int y){
int res = ;
while(y){
if(y & ) res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
y >>= ;
}
return res % mod; //小心模数为1的情况
}
void Pre(){
fac[] = afac[] = ;
for(int i = ; i < MAXN; ++i) fac[i] = 1ll * fac[i - ] * i % mod;
afac[MAXN - ] = Q_pow(fac[MAXN - ],mod - );
for(int i = MAXN - ; i > ; --i) afac[i - ] = 1ll * afac[i] * i % mod;
}
16:内联汇编快速乘法
inline ll mulmod(ll x, ll y, ll mod)
{
ll ret = ;
__asm__("movq %1,%%rax\n imulq %2\n idivq %3\n":"=d"(ret):"m"(x),"m"(y),"m"(mod):"%rax");
return ret;
}
17:扩栈命令
#pragma comment(linker, "/STACK:102400000,102400000")
18:fread 快速读入黑科技
const int BUFSIZE=<<; //根据题目数据而定
char Buf[BUFSIZE+],*buf=Buf;
template<class T>
inline void scan(T&a){
for (a=;*buf<''||*buf>'';buf++);
while (*buf>=''&&*buf<=''){a=a*+(*buf-'');buf++; }
} fread(Buf,,BUFSIZE,stdin); //加到main函数第一行
19:根据日期算星期(基姆拉尔森公式),1~6对应星期一~星期六,0对应星期日
int Cal(int d,int m,int y){
if(m <= ) m += ,y--;
return (d + + * m + * (m + ) / + y + y / - y / + y / ) % ;
}
20:卡特兰数
数列:1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796
h(n)=h(n-1)*(4*n-2)/(n+1);
h(n)=C(2n,n)/(n+1) (n=0,1,2,...)
21:默慈金数
数列:1, 2, 4, 9, 21, 51, 127, 323, 835, 2188, 5798
与卡特兰数的联系:
Common Knowledge的更多相关文章
- Common Knowledge_快速幂
问题 I: Common Knowledge 时间限制: 1 Sec 内存限制: 64 MB提交: 9 解决: 8[提交][状态][讨论版] 题目描述 Alice and Bob play som ...
- sentence patterns
第四部分 推理题 1.世界上每个角落的每个人都有立场,都有背景,都有推理性,能推理出一个人语言的真意,才成就了真正的推理能力: 2.换言之,如果你能通过一个人的说话推理出其身份职业,你的推理能 ...
- jQuery Mobile 脚本加载问题
刚开始使用jQuery Mobile,发现很多问题需要重新考虑,比如脚本加载问题. 在普通html中,如果a.html中有链接到b.html,b.html中有类似代码: $(document).rea ...
- hihocoder 1154 Spring Outing
传送门 #1154 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring ...
- debugging books
https://blogs.msdn.microsoft.com/debuggingtoolbox/2007/06/08/recommended-books-how-to-acquire-or-imp ...
- Creating an API-Centric Web Application[转]
Creating an API-Centric Web Application 转自 http://hub.tutsplus.com/tutorials/creating-an-api-centric ...
- How to Analyze Java Thread Dumps--reference
原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...
- Improving Lock Performance in Java--reference
After we introduced locked thread detection to Plumbr couple of months ago, we have started to recei ...
- python 词云学习
词云入门 三步曲 数据获取:使用爬虫在相关网站上获取文本内容 数据清洗:按一定格式对文本数据进行清洗和提取(文本分类,贴标签) 数据呈现:多维度呈现和解读数据(计算,做表,画图) 一 模块的安装 pi ...
随机推荐
- docker学习-docker仓库
docker仓库中心:https://hub.docker.com/ 网易蜂巢仓库中心:https://c.163.com/hub#/m/home/
- osgEarth的agglite插件使用例子feature_rasterize.earth
<!-- osgEarth Sample Demonstrates use of the "agglite" feature rasterization driver. -- ...
- iOS - UITableView判断reloadData加载数据已经结束
问题: stackoverflow上有人提问这样的问题 http://stackoverflow.com/questions/16071503/how-to-tell-when-uitableview ...
- JSTL中<c:set>标签的用法
<c:set>标签有两种不同的属性设置:var和target. var“版本”用于设置作用域属性,target“版本”用于设置bean属性或Map值. 这两个版本都有两种形式:有标签体和没 ...
- 批量远程执行linux服务器程序--基于paramiko(多线程版)
批量远程执行linux服务器程序--基于paramiko paramiko模块是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接 具体安装方法这里不写,网 ...
- js的delete和void关键字
delete关键字 delete关键字的作用: 删除对象的属性 语法:delete 对象.属性 可以删除没有使用var关键字声明的全局变量(直接定义在window上面的属性) delete关键字的 ...
- 问答项目---金币经验奖励规则及网站配置写入config文件
具体步骤: 引入配置文件——>获取当前数组——>进行合并 public function edit(){ //引入 config.php配置文件 $file = APP_PATH.'Com ...
- rest_framework之版本详解 04
访问不同版本,给不同内容. rest规范:版本要么放url上:要么放请求头里. 1.原来的url的版本都写死了.只能写v1 from django.conf.urls import url from ...
- 删除Excel中的复选框等控件
- pta 习题集5-19 列车厢调度
1 ====== <--移动方向 / 3 ===== \ 2 ====== -->移动方向 大家或许在某些数据结构教材上见到过"列车厢调度问题"(当然没见过也不要紧). ...