期待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=1;
        for(;_b;_b >>= 1, _a= _a * _a % _mod)
          if(_b & 1) _res = _res * _a % _mod;
        return _res ;
    }

template<typename _Element_gcd>
  _Element_gcd
    _gcd(_Element_gcd _m, _Element_gcd _n)
    {
        while (_n != 0)
        {
          _Element_gcd _t = _m % _n;
          _m = _n;
          _n = _t;
        }
      return _m;
    }


    bool __check[1000010];
    int __size;
    int _num[1000010];
    void _prime(int __n)
    {
      for(int _i=2;_i<=__n;_i++)
        {
          if(!__check[_i]) _num[__size++]=_i;
          for(int _j=0;_j<__size;_j++)
          {
            if(_i*_num[_j]>__n) break;
            __check[_num[_j]*_i]=1;
            if(_i%_num[_j]==0) break;
          }
        }
      return ;
    }
    bool _isprime(int __n) {return ~__check[__n];}

 

template<typename _Element_stack>
struct _stack{
    _Element_stack __st[100010];
    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==0;}
};

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)0?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[ 1 << 25 ], *pin ,  
      outbuf[ 1 << 25 ], *pout ;
    int stk[ 20 ] ;

    file_io():
      pout( outbuf ) { 
        fread( pin = inbuf, 1, 1 << 25 , stdin );
    }
    
    ~file_io() {
        fwrite( outbuf , 1 , pout - outbuf , stdout ) ;
    }

    inline void 
      getint( int &num ){
            bool
              neg = 0 ;
            num = 0;
            while( !isdigit( *pin ))
              if( *pin++ ==  '-' )
                neg = 1;
            while( isdigit( *pin ))
              num = num * 10 + *pin++ - '0';
            if( neg )
              num = -num;
        }

    inline void
      putint( int num ){
            static int
              *v = stk;
            if( !num )
              *pout++ = '0';
            else{
                if( num < 0)
                  *pout++ = '-', num = -num;
                for( ; num ; num /= 10)
                  *v++ = num % 10;
                while(v != stk ) 
            *pout++ = *--v + '0';
            }
        }

    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[210][210];
    int  siz;
    friend _Martix operator*
      ( const _Martix &__a,const _Martix &__b)
        {
            _Martix __c;
            int _n
                = _max ( __a.siz , __b.siz );

            for( int _k = 0 ; _k < _n ; _k ++ )
                for( int _i = 0 ; _i < _n ; _i ++ )
                    for( int _j = 0; _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 = 0 ; _i < _n ; _i ++ )
                    for( int _j = 0; _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 = 0 ; _i < _n ; _i ++ )
                    for( int _j = 0; _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 ? -1 : x > eps ;}
        
    inline double
    _getnum(){
        double ans = 1.0 ;
        for( int i = 1 ; i <= siz ; i ++ ){
            int nw = i;
            for( int j = i + 1 ; j <= siz ; j ++ )
                if(_fabs(num[j][i]) > _fabs(num[nw][i]))
                    nw=j;
            
            for( int j = 1 ; j <= siz ; j ++ )
                _swap(num[nw][j],num[i][j]);
            
            for( int j = i + 1 ; 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$注釋掉了,因為本寶寶寫掛了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM