Small but Funny Tricks [Remember them all!]
- 模数 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;
}
- 有标号联通无向图计数中的这个卷积:
\]
可以导出 \(A=B\times C\) 从而推出 \(B= A\times C^{-1}\), 因为 \((-1)!=+\infty\),所以上面的式子可以改写为从 0 开始求和(当然还是整数的方程辣),并且 \(C_0=1\), \(C\) 存在逆元.
Small but Funny Tricks [Remember them all!]的更多相关文章
- testng 教程之使用参数的一些tricks配合使用reportng
前两次的总结:testng annotation生命周期 http://www.cnblogs.com/tobecrazy/p/4579414.html testng.xml的使用和基本配置http: ...
- (转) 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 ...
- Matlab tips and tricks
matlab tips and tricks and ... page overview: I created this page as a vectorization helper but it g ...
- LoadRunner AJAX TruClient协议Tips and Tricks
LoadRunner AJAX TruClient协议Tips and Trickshttp://automationqa.com/forum.php?mod=viewthread&tid=2 ...
- 【翻译】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 ...
- 神经网络训练中的Tricks之高效BP(反向传播算法)
神经网络训练中的Tricks之高效BP(反向传播算法) 神经网络训练中的Tricks之高效BP(反向传播算法) zouxy09@qq.com http://blog.csdn.net/zouxy09 ...
- Hex-Rays Decompiler Tips and tricks Volatile memory
https://www.hex-rays.com/products/decompiler/manual/tricks.shtml First of all, read the troubleshoot ...
- hdu 5276 YJC tricks time 数学
YJC tricks time Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- 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( ...
- Git tricks: Unstaging files
NOTE: Following content is directly reprinted from http://andrewberls.com/blog/post/git-tricks-unsta ...
随机推荐
- 【UE4 C++】绘制函数 Debug drawing functions
基于UKismetSystemLibrary /** Draw a debug line */ UFUNCTION(BlueprintCallable, Category="Renderin ...
- kivy浮点布局
from kivy.app import App from kivy.uix.floatlayout import FloatLayout class FloatLayoutWidget(FloatL ...
- 利用DMA实现采样数据的直接搬运存储
尝试了下STM32的ADC采样,并利用DMA实现采样数据的直接搬运存储,这样就不用CPU去参与操作了. 找了不少例子参考,ADC和DMA的设置了解了个大概,并直接利用开发板来做一些实验来验证相关的操作 ...
- 必备的60个常用的Linux命令
Linux必学的60个命令Linux提供了大量的命令,利用它可以有效地完成大量的工 作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令. ...
- STM32中按键中断分析
在按键学习中,我们有用到查询的方法来判断按键事件是否发生,这种查询按键事件适用于程序工作量较少的情况下,一旦程序中工作量较大较多,则势必影响程序运行的效率,为了简化程序中控制的功能模块的执行时间,引入 ...
- 攻防世界 杂项 2.embarrass
解1: linux环境下直接strings misc_02.pcapng | grep flag可得flag. 解2: 使用wireshark搜索flag. 解3: winhex搜索flag.
- Python SyntaxError: Missing parentheses in call to 'print'
下面的代码 print "hello world" 会出现下面的错误 SyntaxError: Missing parentheses in call to 'print' 因为写 ...
- dubbo 配置 loadbalance 不生效?撸一把源码
背景 很久之前我给业务方写了一个 dubbo loadbalance 的扩展(为了叙述方便,这个 loadbalance 扩展就叫它 XLB 吧),这两天业务方反馈说 XLB 不生效了 我心想,不可能 ...
- Spring Cloud Gateway 整合阿里 Sentinel网关限流实战!
大家好,我是不才陈某~ 这是<Spring Cloud 进阶>第八篇文章,往期文章如下: 五十五张图告诉你微服务的灵魂摆渡者Nacos究竟有多强? openFeign夺命连环9问,这谁受得 ...
- 自动化SQL注入工具 sqlmap 使用手册
0x00 sqlmap介绍 什么是sqlmap? sqlmap是一个开源的渗透测试工具,它自动化了检测和利用SQL注入缺陷 以及接管数据库服务器的过程.它配备了一个强大的检测引擎 ,以及终极渗透测试仪 ...