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:卡哈希

  参考codeforces博文

  参考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的更多相关文章

  1. Common Knowledge_快速幂

    问题 I: Common Knowledge 时间限制: 1 Sec  内存限制: 64 MB提交: 9  解决: 8[提交][状态][讨论版] 题目描述 Alice and Bob play som ...

  2. sentence patterns

    第四部分     推理题 1.世界上每个角落的每个人都有立场,都有背景,都有推理性,能推理出一个人语言的真意,才成就了真正的推理能力: 2.换言之,如果你能通过一个人的说话推理出其身份职业,你的推理能 ...

  3. jQuery Mobile 脚本加载问题

    刚开始使用jQuery Mobile,发现很多问题需要重新考虑,比如脚本加载问题. 在普通html中,如果a.html中有链接到b.html,b.html中有类似代码: $(document).rea ...

  4. hihocoder 1154 Spring Outing

    传送门 #1154 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring ...

  5. debugging books

    https://blogs.msdn.microsoft.com/debuggingtoolbox/2007/06/08/recommended-books-how-to-acquire-or-imp ...

  6. Creating an API-Centric Web Application[转]

    Creating an API-Centric Web Application 转自 http://hub.tutsplus.com/tutorials/creating-an-api-centric ...

  7. How to Analyze Java Thread Dumps--reference

    原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...

  8. Improving Lock Performance in Java--reference

    After we introduced locked thread detection to Plumbr couple of months ago, we have started to recei ...

  9. python 词云学习

    词云入门 三步曲 数据获取:使用爬虫在相关网站上获取文本内容 数据清洗:按一定格式对文本数据进行清洗和提取(文本分类,贴标签) 数据呈现:多维度呈现和解读数据(计算,做表,画图) 一 模块的安装 pi ...

随机推荐

  1. mySQL数据库二:命令行的使用

    在做整理的时候,上一篇刚开始只是简单的做了个数据类型的开头,在这里简单说一下mySQL的使用以及它的命令行 1.准备工作 有一个好的开发工具可以几何倍数的增加我们的工作效率,所以,工具是必不可少的,首 ...

  2. beginUpdates和endUpdates-实现UITableView的动画块

    我们在做UITableView的修改,删除,选择时,需要对UITableView进行一系列的动作操作. 这样,我们就会用到 [tableView beginUpdates]; if (newCount ...

  3. Apktool源码解析——第一篇

    著名的apktool是android逆向界用的最普遍的一个工具,这个项目的原始地址在这里http://code.google.com/p/android-apktool/,但是你们都懂的在天朝谷歌是无 ...

  4. 【thinkphp5】 分页样式修改

    1 找到文件:/thinkphp/library/think/paginator/driver/Bootstrap.php <?php // +------------------------- ...

  5. yield方法

    yield方法的作用是房企当前的CPU资源,将他让给其他的任务去占用CPU执行时间,但房企的时间不确定,有可能刚刚放弃,马上又获得CPU时间片. package yield; /** * Create ...

  6. JS-随机div颜色

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. Windows Phone 7 检查手机网络

    using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Wi ...

  8. windows系统常用软件及配置介绍

    常用工具 ,,,, 开发工具 ,,, 快捷键 ... 等等 vvv 等等

  9. OneThink友情链接插件使用!

    OneThink友情链接插件使用: 直接安装插件就好,查看数据库会有:onethink_links 这个表: 写 links 标签,调用友情链接: <?php namespace Common\ ...

  10. AVG

    AVG([ DISTINCT | ALL ] expr) [ OVER(analytic_clause) ] SELECT MANAGER_ID,           LAST_NAME,       ...