小椛椛的板子们

Posted ZlycerQan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小椛椛的板子们相关的知识,希望对你有一定的参考价值。

 

实在不愿意再做题了,这几天写写板子。

 

Lucas

 

#include <cstdio>
#include <iostream>
#define rg register
inline void read (long long &n)
{
    rg char c = getchar ();
    for (n = 0; !isdigit (c); c = getchar ());
    for (; isdigit (c); n = n * 10 + c - 0, c = getchar ());
}
#define Max 1213231
typedef long long LL; LL fac[Max];
LL Pow (LL x, LL p, LL mo)
{
    LL a = x, res = 1;
    for (; p; p >>= 1, a *= a, a %= mo)
        if (p & 1) res *= a, res %= mo;
    return res % mo;
}
LL C (LL N, LL M, LL p) 
{ return M > N ? 0 : ((fac[N] * Pow (fac[M], p - 2, p)) % p * Pow (fac[N - M], p - 2, p) % p); }
LL Lucas (LL N, LL M, LL P) 
{ return !M ? 1 : (C (N % P, M % P, P) * Lucas (N / P, M / P, P)) % P; }
int main (int argc, char *argv[])
{
    LL T, x, y, p, L; read (T); rg int i;
    for (fac[0] = 1; T; -- T)
    {
        read (x), read (y), read (p);
        for (i = 1; i <= p; ++ i) fac[i] = fac[i - 1] * i, fac[i] %= p;
        printf ("%lld\n", Lucas (x + y, x, p));
    }
    return 0;
}

 

快速排序

虽然说不让用sort,但是我这种懒癌晚期的人怎么可能去手写sort呢?【其实是不会写

觉得过意不去,就写了快读和快输

#include <cstdio>
#include <iostream>
#include <algorithm>
struct io
{
    static const int BUF = 12310330;
    char p[BUF], *s, e[BUF], *t; int a[24];
    io () : s(p), t(e) { fread (s, 1, sizeof p, stdin); }
    ~io () { fwrite (e, 1, t - e, stdout); }
    operator int()
    {
        static int v,j;
        v = 0,j = 1;
        for (v = 0, j = 1; *s < 48; j = *s++ ^ 45);
        do v = v * 10 + *s++ - 48; while (*s > 32);
        return j ? v : -v;
    }
    void print(int v)
    {
        static int *q = a;
        if (!v) *t++ = 48;
        else
        {
            if (v < 0) *t++ = 45, v *= -1;
            for (; v; *q++ = v % 10 + 48, v /= 10);
            for (; q != a; *t++ = *--q);
        }
        *t++ = 32;
    }
} ip;
#define Max 100007
int a[Max]; 
int main (int argc, char *argv[])
{
#define rg register
    int N = ip; rg int i;
    for (i = 1; i <= N; ++ i) a[i] = ip;
    std :: sort (a + 1, a + 1 + N);
    for (i = 1; i <= N; ++ i) ip.print (a[i]);
    return 0;
}

 

以上是关于小椛椛的板子们的主要内容,如果未能解决你的问题,请参考以下文章

板子们~

到处偷的板子们。。。。

NOIP的板子们 (未完待续)

c#代码片段快速构建代码

一道状压板子题题解By 云岁月书 2020/7/16

推荐net开发cad入门阅读代码片段