1. 模数 1e9 的神奇求行列式:
#include <bits/stdc++.h>

using namespace std; const int maxn = 1e2, mod = 1e9;

#define n N

int n, a[maxn][maxn]; inline int det()
{
//cout << n << endl;
int ans = 1; for (int i = 1; i <= n; i++)
{
for (int k = i + 1; k <= n; k++) while (a[k][i])
{
int d = a[i][i] / a[k][i];
for (int j = i; j <= n; j++) a[i][j] = (a[i][j] - 1ll * d * a[k][j] % mod + mod) % mod;
swap(a[i], a[k]), ans *= -1;
}
ans = (ans * 1ll * a[i][i]) % mod/*, cout << ans << endl*/;
}
return (ans % mod + mod) % mod;
} #undef n inline void add(int u, int v) { a[u][v]--, a[v][u]--, a[u][u]++, a[v][v]++; /*cout << 'H' << u << v << endl;*/ } char s[maxn][maxn]; int n, m, num[maxn][maxn]; int main()
{
ios::sync_with_stdio(0), cin.tie(0), cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { cin >> s[i][j]; if (s[i][j] == '.') num[i][j] = ++N; }
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (num[i][j])
{
if (num[i][j + 1]) add(num[i][j], num[i][j + 1]); if (num[i + 1][j]) add(num[i][j], num[i + 1][j]);
}
N--, cout << det() << endl;
}
  1. 有标号联通无向图计数中的这个卷积:
\[\frac{f_n}{(n-1)!}=\sum_{i=1}^n \frac{g_i}{(i-1)!} \cdot \frac{f_{n-i}}{(n-i)!}
\]

可以导出 \(A=B\times C\) 从而推出 \(B= A\times C^{-1}\), 因为 \((-1)!=+\infty\),所以上面的式子可以改写为从 0 开始求和(当然还是整数的方程辣),并且 \(C_0=1\), \(C\) 存在逆元.

Small but Funny Tricks [Remember them all!]的更多相关文章

  1. testng 教程之使用参数的一些tricks配合使用reportng

    前两次的总结:testng annotation生命周期 http://www.cnblogs.com/tobecrazy/p/4579414.html testng.xml的使用和基本配置http: ...

  2. (转) How to Train a GAN? Tips and tricks to make GANs work

    How to Train a GAN? Tips and tricks to make GANs work 转自:https://github.com/soumith/ganhacks While r ...

  3. Matlab tips and tricks

    matlab tips and tricks and ... page overview: I created this page as a vectorization helper but it g ...

  4. LoadRunner AJAX TruClient协议Tips and Tricks

    LoadRunner AJAX TruClient协议Tips and Trickshttp://automationqa.com/forum.php?mod=viewthread&tid=2 ...

  5. 【翻译】C# Tips & Tricks: Weak References - When and How to Use Them

    原文:C# Tips & Tricks: Weak References - When and How to Use Them Sometimes you have an object whi ...

  6. 神经网络训练中的Tricks之高效BP(反向传播算法)

    神经网络训练中的Tricks之高效BP(反向传播算法) 神经网络训练中的Tricks之高效BP(反向传播算法) zouxy09@qq.com http://blog.csdn.net/zouxy09 ...

  7. Hex-Rays Decompiler Tips and tricks Volatile memory

    https://www.hex-rays.com/products/decompiler/manual/tricks.shtml First of all, read the troubleshoot ...

  8. hdu 5276 YJC tricks time 数学

    YJC tricks time Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

  9. 10 Interesting Linux Command Line Tricks and Tips Worth Knowing

    I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...

  10. Git tricks: Unstaging files

    NOTE: Following content is directly reprinted from http://andrewberls.com/blog/post/git-tricks-unsta ...

随机推荐

  1. 【UE4 设计模式】单例模式 Singleton Pattern

    概述 描述 保证一个类只有一个实例 提供一个访问该实例的全局节点,可以视为一个全局变量 仅在首次请求单例对象时对其进行初始化. 套路 将默认构造函数设为私有, 防止其他对象使用单例类的 new运算符. ...

  2. BUAA2020软工作业(五)——软件案例分析

    项目 内容 这个作业属于哪个课程 2020春季计算机学院软件工程(罗杰 任健) 这个作业的要求在哪里 软件案例分析作业 我在这个课程的目标是 进一步提高自己的编码能力,工程能力 这个作业在哪个具体方面 ...

  3. 基于docker-compose搭建sonarqube代码质量检测平台

    一.需求 在我们开发的过程中,难免有时候代码写的不规范,或存在一些静态的bug问题,这个时候一个良好的代码检查工具就很有必要,而sonarqube正好可以满足整个要求. 二. docker-compo ...

  4. NGINX杂谈——flask_limiter的IP获取(怎么拿到真实的客户端IP)

    本篇博客将 flask_limiter 作为切入点,来记录一下自己对 remote_addr 和 proxy_add_x_forwarded_for 两个变量.X-Real-IP 和 X-Forwar ...

  5. MIPI的走线阻抗

    MIPI的走线阻抗100欧的要求是根据LVDS(Low Voltage Differential Signaling)电平定义的. LVDS差分信号PN两线最大幅度是350mV,内部一个恒流源电流是3 ...

  6. python 修饰器(decorator)

    转载:Python之修饰器 - 知乎 (zhihu.com) 什么是修饰器,为什么叫修饰器 修饰器英文是Decorator, 我们假设这样一种场景:古老的代码中有几个很是复杂的函数F1.F2.F3.. ...

  7. systemverilog 字符串类型

    转载:https://blog.csdn.net/Holden_Liu/article/details/100727957 传统的Veriog仅仅支持文字表述上的字符串, 而SystemVerilog ...

  8. sort-list leetcode C++

    Sort a linked list in O(n log n) time using constant space complexity. C++ /** * Definition for sing ...

  9. Python里字符串Format时的一个易错“点”

    这是一篇很小的笔记,原因是我做学习通的时候见到了这个题: 当时看了一会儿发现没有符合自己想法的答案,然后就脑袋一热选了C,结果当然是错了... 看了一眼这个format的字符串对象,发现有个 {:7. ...

  10. 设计模式二--模板方法Template method

    模式分类: 书籍推荐:重构-改善既有代码的设计 重构获得模式 设计模式:现代软件设计的特征是"需求的频繁变化".设计模式的要点是 "寻找变化点,然后在变化点处应用设计模式 ...