期待suqingnian.h
不定期更新,跟着自己的进度走的。
有什么好的东西可以收录的尽管留言
UPD:话说真的没人发现本宝宝的$Martix$类的$operator$打错了么?$qwq$ $2018.7.19$
/*by Qingnian Su,Only want to write sonething useful*/
#ifndef suqingnian
#define suqingnian template<typename _Element_pow>
_Element_pow
_pow(_Element_pow _a,_Element_pow _b,_Element_pow _mod)
{
_Element_pow _res=;
for(;_b;_b >>= , _a= _a * _a % _mod)
if(_b & ) _res = _res * _a % _mod;
return _res ;
} template<typename _Element_gcd>
_Element_gcd
_gcd(_Element_gcd _m, _Element_gcd _n)
{
while (_n != )
{
_Element_gcd _t = _m % _n;
_m = _n;
_n = _t;
}
return _m;
} bool __check[];
int __size;
int _num[];
void _prime(int __n)
{
for(int _i=;_i<=__n;_i++)
{
if(!__check[_i]) _num[__size++]=_i;
for(int _j=;_j<__size;_j++)
{
if(_i*_num[_j]>__n) break;
__check[_num[_j]*_i]=;
if(_i%_num[_j]==) break;
}
}
return ;
}
bool _isprime(int __n) {return ~__check[__n];} template<typename _Element_stack>
struct _stack{
_Element_stack __st[];
int __size_st;
void __push(_Element_stack __x)
{__st[++__size_st]=__x;return ;}
void __pop()
{__size_st--;return ;}
_Element_stack __top()
{return __st[__size_st];}
bool _empty() {return __size_st==;}
}; template<typename _Element_compare_max>
_Element_compare_max
_max(
const _Element_compare_max &a,
const _Element_compare_max &b )
{ return a > b ? a : b ;} template<typename _Element_compare_min>
_Element_compare_min
_min(
const _Element_compare_min &a,
const _Element_compare_min &b )
{ return a > b ? b : a ;} template<typename _Element_fabs>
_Element_fabs
_fabs(
const _Element_fabs &a )
{return a>(_Element_fabs)?a:-a;} template<typename _Element_swap>
void
_swap(
_Element_swap &a,
_Element_swap &b ){
a^=b^=a^=b;
return ;
} #include<cstdio>
struct file_io{
#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
char inbuf[ << ], *pin ,
outbuf[ << ], *pout ;
int stk[ ] ; file_io():
pout( outbuf ) {
fread( pin = inbuf, , << , stdin );
} ~file_io() {
fwrite( outbuf , , pout - outbuf , stdout ) ;
} inline void
getint( int &num ){
bool
neg = ;
num = ;
while( !isdigit( *pin ))
if( *pin++ == '-' )
neg = ;
while( isdigit( *pin ))
num = num * + *pin++ - '';
if( neg )
num = -num;
} inline void
putint( int num ){
static int
*v = stk;
if( !num )
*pout++ = '';
else{
if( num < )
*pout++ = '-', num = -num;
for( ; num ; num /= )
*v++ = num % ;
while(v != stk )
*pout++ = *--v + '';
}
} inline void
nextline() {
*pout++ = '\n';
}
}fio;
#define getint(num) fio.tint(num)
#define putint(num) fio.putint(num)
#define nextline() fio.nextline()
//template<typename _Element_Martix>
const double eps=0.00000000000000000001;
struct _Martix{
int
num[][];
int siz;
friend _Martix operator*
( const _Martix &__a,const _Martix &__b)
{
_Martix __c;
int _n
= _max ( __a.siz , __b.siz ); for( int _k = ; _k < _n ; _k ++ )
for( int _i = ; _i < _n ; _i ++ )
for( int _j = ; _j < _n ; _j ++ )
__c.num[_i][_j] +=
__a.num[_i][_k] * __b.num[_k][_j] ; __c.siz = _n;
return __c;
} friend _Martix operator+
( const _Martix &__a,const _Martix &__b)
{
_Martix __c;
int _n
= _max ( __a.siz , __b.siz );
for( int _i = ; _i < _n ; _i ++ )
for( int _j = ; _j < _n ; _j ++ )
__c.num[_i][_j] = __a.num[_i][_j] + __b.num[_i][_j] ;
__c.siz = _n;
return __c;
} friend _Martix operator-
( const _Martix &__a,const _Martix &__b)
{
_Martix __c;
int _n
= _max ( __a.siz , __b.siz );
for( int _i = ; _i < _n ; _i ++ )
for( int _j = ; _j < _n ; _j ++ )
__c.num[_i][_j] = __a.num[_i][_j] - __b.num[_i][_j] ;
__c.siz = _n;
return __c;
}
/*
inline int* operator []
( const int& __x )
{return num[__x];} inline bool cmp(const double &x){
return x < -eps ? - : x > eps ;} inline double
_getnum(){
double ans = 1.0 ;
for( int i = ; i <= siz ; i ++ ){
int nw = i;
for( int j = i + ; j <= siz ; j ++ )
if(_fabs(num[j][i]) > _fabs(num[nw][i]))
nw=j; for( int j = ; j <= siz ; j ++ )
_swap(num[nw][j],num[i][j]); for( int j = i + ; j <= siz ; j ++ ){
double t = num[j][i]/num[i][i];
for( int k = i ; k <= siz ; k ++ )
num[j][k] -= num[i][k] * t;
} if(!cmp(num[i][i])) return 0.0;
ans *= num[i][i];
}
return _fabs( ans );
}
*/
};
#endif
本宝宝暂时把$128int$注释掉了,因为本宝宝写挂了。
期待suqingnian.h的更多相关文章
- bzoj1050旅行
题目链接 其实没有辣么难, 暴力枚举最小边是哪条边,然后每次跑一边最小生成树, 当$s,t$刚好联通时最后加的边的权值就是当前的最大边最小的情况 然后判断一下,更新答案就好 /************ ...
- bzoj1875 HH去散步
题目链接 一开始特别天真, $Folyd$传递闭包写了一下过了样例就交上去了 然后$gg$ $qwq$ 想了想$……$ 还要写一点东西 最后统计答案的时候有细节要注意 /*************** ...
- bzoj1801中国象棋
题目链接 很裸的$dp+$组合计数 注意 注意 注意 $BZOJ$不要用玄学优化 $CE$不管$qwq$ /********************************************** ...
- bzoj1009GT考试
题目链接 没啥好说的,矩阵优化+$kmp$字符串匹配 上代码: /************************************************************** Prob ...
- bzoj2440完全平方数
题目链接 上来先吐槽题面!!!!!! 你跟我说$1$不是完全平方数昂? 看了半天样例啊. 活生生的半天$……$ 莫比乌斯 反演 函数容斥一下,每次二分就好 反正本宝宝不知道反演是啥. 每次判断应 ...
- Android IOS WebRTC 音视频开发总结(七九)-- WebRTC选择H.264的四大理由
本文主要介绍WebRTC选择H.264的理由(我们翻译和整理的,译者:weizhenwei,校验:blacker),最早发表在[编风网] 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacke ...
- 彻底弄清c标准库中string.h里的常用函数用法
在我们平常写的c/c++程序,一些算法题中,我们常常会用到c标准库中string.h文件中的函数,这些函数主要用于处理内存,字符串相关操作,是很有用的工具函数.而且有些时候,在笔试或面试中也会出现让你 ...
- vlc源码分析(六) 调用OpenMAX硬解码H.265
H.265(HEVC)编码格式能够在得到相同编码质量视频的前提下,使用相当于H.264(AVC)一半的存储容量,虽然H.265的算法复杂度比H.264高一个数量级,但是硬件水平在不断提高,因此H.26 ...
- STL stl_alloc.h
# // Comment By: 凝霜 # // E-mail: mdl2009@vip.qq.com # // Blog: http://blog.csdn.net/mdl13412 # # // ...
随机推荐
- 1.1.Task Queue
任务队列是一种跨线程.跨机器工作的一种机制. 任务队列中包含称作任务的工作单元.有专门的工作进程持续不断的监视任务队列,并从中获得新的任务并处理. celery通过消息进行通信,通常使用一 ...
- How to Change Master Page @ Run-time
This tip will give complete knowledge of how to change master page, render controls and accessing it ...
- ACCESS中如何比较日期和时间,使用DateDiff函数
DateDiff,语法如下:DateDiff( 间隔字符, 日期1, 日期2 [,firstdayofweek[, firstweekofyear]])一般使用 DateDiff( 间隔字符, 日期1 ...
- php 5.3 以上fpm安装
安装PHP #wget http://cn2.php.net/get/php-5.3.8.tar.gz/from/cn.php.net/mirror #tar -zxvf php-5.3.8.tar. ...
- jQuery div鼠标移动效果
<head runat="server"> <meta http-equiv="Content-Type" content="tex ...
- Solidity transfer vs send 区别
原文地址: https://ethereum.stackexchange.com/questions/19341/address-send-vs-address-transfer-best-pract ...
- Hyperledger Fabric Orderer节点启动
Orderer 节点启动通过 orderer 包下的 main() 方法实现,会进一步调用到 orderer/common/server 包中的 Main() 方法. 核心代码如下所示. // Mai ...
- php手机号正则
preg_match("/^1[34578]{1}\d{9}$/", $phone)
- Classification and Prediction
# coding: utf-8 # In[128]: get_ipython().magic(u'matplotlib inline') import pandas as pd from pandas ...
- c# 多维数组、交错数组(转化为DataTable)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...