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 ...
随机推荐
- QQ消算轰炸,我好无聊真的
from pynput.keyboard import Key,Controller import time from random import choice time.sleep(5) # 创建键 ...
- django 中的hello word 开心,通过申请博客了,,发个随笔庆祝一下~~~~~~~
django 中的hello word! 准备:[pymsql,pycharm,django3.0.7] >>>终端中:django-admin.py startproject [项 ...
- Java中的函数式编程(八)流Stream并行编程
写在前面 在本系列文章的第一篇,我们提到了函数式编程的优点之一是"易于并发编程". Java作为一个多线程的语言,它通过 Stream 来提供了并发编程的便利性. 题外话: 严格来 ...
- AIApe问答机器人Scrum Meeting 4.27
Scrum Meeting 3 日期:2021年4月27日 会议主要内容概述:汇报两日工作. 一.进度情况 组员 负责 两日内已完成的工作 后两日计划完成的工作 工作中遇到的困难 李明昕 后端 Tas ...
- [no code][scrum meeting] Alpha 2
项目 内容 会议时间 2020-04-07 会议主题 功能规格说明书review 会议时长 30min 参会人员 OCR组(肖思炀,赵涛)和产品经理 $( "#cnblogs_post_bo ...
- 15个问题自查你真的了解java编译优化吗?
摘要:为什么C++的编译速度会比java慢很多?二者运行程序的速度差异在哪? 了解了java的早期和晚期过程,就能理解这个问题了. 本文分享自华为云社区<你真的了解java编译优化吗?15个问题 ...
- 极速上手 VUE 3—v-model 的使用变化
本篇文章主要介绍 v-model 在 Vue2 和 Vue3 中使用变化. 一.Vue2 中 v-model 的使用 v-model 是语法糖,本质还是父子组件间的通信.父子组件通信时有两种方式: 父 ...
- C++中gSOAP的使用
目录 SOAP简介 gSOAP 准备工作 头文件 构建客户端应用程序 生成soap源码 建立客户端项目 构建服务端应用程序 生成SOAP源码 建立服务端项目 打印报文 SOAP测试 项目源码 本文主要 ...
- JMeter学习笔记--录制脚本(一)
---------------------------------------------------------------------------------------------------- ...
- idea查看方法在哪里被调用
方法一 选中方法名,右键选择Find Usages 方法二 选中方法快捷键ctrl + alt + h查看Hierarchy Callers