zoukankan      html  css  js  c++  java
  • 头文件

    #include<bits/stdc++.h>
    #define fi first
    #define se second
    #define io std::ios::sync_with_stdio(false)
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    const ll mod=1e9+7,INF = 0x3f3f3f3f;
    ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    ll exgcd(ll a, ll b, ll &x, ll &y) {if(!b) {x = 1; y = 0; return a;}ll r = exgcd(b, a % b, x, y);ll tmp = x; x = y, y = tmp - a / b * y;return r;}
    ll qpow(ll a,ll n){ll r=1%mod;for (a%=mod; n; a=a*a%mod,n>>=1)if(n&1)r=r*a%mod;return r;}
    ll qpow(ll a,ll n,ll P){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
    ll EX_BSGS(ll a,ll b,ll p){if(b == 1) return 0;map<ll,ll> pw;ll cnt = 0, t = 1, s, x, m;for(ll d = gcd(a, p); d != 1; d = gcd(a, p)){if(b % d) return -1;++cnt, b /= d, p /= d, t = 1LL * t * a / d % p;
    if(b == t) return cnt;}s = b, m = sqrt(p) + 1;for(ll i = 0; i < m; ++i){pw[s] = i;s = 1LL * s * a % p;}x = qpow(a, m, p), s = t;for(ll i = 1; i <= m; ++i){s = 1LL * s * x % p;if(pw.count(s)) return i * m - pw[s] + cnt;
    }return -1;} //拔山盖世!
    /*ll _next[maxn*2],head[maxn],tot,to[maxn*2];
    void add(ll x,ll y)
    {
    _next[++tot]=head[x],head[x]=tot,to[tot]=y;
    //_next[++tot]=head[y],head[y]=tot,to[tot]=x;
    }*/
  • 相关阅读:
    (转) 建立自己的MemberShip数据库
    '??' 语法
    c# 静态构造函数(转)
    ReSharp+VAssistX+VS2003 的个人设置
    支持多种数据类型的ListView排序
    学习笔记
    Java实验报告(实验二)
    Java实验报告(实验一)
    java数组中null和空的区别。
    网页选项卡功能
  • 原文地址:https://www.cnblogs.com/acmLLF/p/13713243.html
Copyright © 2011-2022 走看看