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. 如何将jdk12的源码导入idea

    如何将jdk12的源码导入idea中 一 首先,在idea中新建一个java工程 接着,在本地找到jdk所在的文件目录,进入jdk目录,找到javasrc目录或者一个src.zip的压缩包, 在向下或 ...

  2. [no code][scrum meeting] Beta 5

    $( "#cnblogs_post_body" ).catalog() 例会时间:5月18日14:30,主持者:叶开辉 下次例会时间:5月19日11:30,主持者:黎正宇 一.工作 ...

  3. Beta阶段第一次会议

    Beta阶段第一次例会 时间:2020.5.16 完成工作 姓名 完成任务 难度 完成度 lm 1.修订网页端信息编辑bug2.修订网页端登录bug(提前完成,相关issue已关闭) 中 100% x ...

  4. BUAA 2020 软件工程 个人博客作业

    BUAA 2020 软件工程 个人博客作业 Author: 17373051 郭骏 项目 内容 这个作业属于哪个课程 2020春季计算机学院软件工程(罗杰 任健) 这个作业的要求在哪里 个人博客作业 ...

  5. 2021.9.13考试总结[NOIP模拟52]

    T1 路径 考虑每一位的贡献,第$i$位每$2^i$个数会变一次,那么答案为$\sum_{i=1}^{log_2n} \frac{n}{2^i}$. $code:$ 1 #include<bit ...

  6. 单片机stm32 USART串口实际应用解析

    stm32作为现在嵌入式物联网单片机行业中经常要用多的技术,相信大家都有所接触,今天这篇就给大家详细的分析下有关于stm32的出口,还不是很清楚的朋友要注意看看了哦,在最后还会为大家分享有些关于stm ...

  7. Get value from agent failed: cannot connect to [[192.168.8.102]:10050]: [113] No route to host

    192.168.8.102主机down掉,开机就可以

  8. (一)《SQL进阶教程》学习记录--CASE

    背景:最近用到统计之类的复杂Sql比较多,有种"提笔忘字"的感觉,看书练习,举一反三,巩固加强. (一) <SQL进阶教程>学习记录--CASE (二) <SQL ...

  9. maven项目中 把依赖包打进jar包

    在pom.xml文件中增加build配置 1 <build> 2 <plugins> 3 <plugin> 4 <artifactId>maven-as ...

  10. tabulate

    ValueError: headers for a list of dicts is not a dict or a keyword from: https://bitbucket.org/astan ...